How to fix TensorFlow library was compiled to use SSE4.1 instructions, but these aren’t available on your machine. Aborted

Do you get the following error while trying to use TensorFlow on a Linux virtual machine?

TensorFlow library was compiled to use SSE4.1 instructions, but these aren't available on your machine. Aborted.

This might be caused by your CPU that is unsupported. If you are running TensorFlow in a virtual machine, then check how your virtual CPU is configured (what type). Do this by typing the following in your Linux terminal:

cat /proc/cpuinfo

This should give you the following output:

user@Ubuntu:~$ cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 6
model name	: Common KVM processor
stepping	: 1
microcode	: 0x1000065
cpu MHz		: 3393.624
cache size	: 512 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 4
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid tsc_known_freq pni cx16 x2apic hypervisor cmp_legacy 3dnowprefetch vmmcall
bugs		: fxsave_leak sysret_ss_attrs swapgs_fence spectre_v1 spectre_v2
bogomips	: 6787.24
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

Take a good look at the following line:

model name	: Common KVM processor

In some virtualization software, for example Proxmox, the CPU is configured (or better said: masked) as a generic CPU type which is independent from the actual CPU in the server. You can see this because instead of a brand name “Intel i7 xxxx” or “Intel Xeon xxxx” it says “Common KVM processor”.

The reason why most virtualization platforms default to using a generic CPU type, is because this has certain benefits where you can move a VM between physical hosts with different CPU’s, without the CPU type changing in the VM. So the actual CPU implementation is also virtualized this way.

However in certain cases this causes issues when software requires certain CPU functionalities that isn’t available in this “generic” CPU type.

Solution: change your vCPU type

The solution? Configure your virtual machine’s CPU as “[host]” or equivalent config value in your virtualization software. What you want is that the actual CPU of your host is shown to your VM.

In Proxmox for example, you need to go to the “hardware” tab of your VM and configure the processors/CPU type like this:

Changing CPU type of virtual machine to [host]

This will make it so that the actual CPU of the host machine is what is shown to the VM. The server used in this example has a “AMD Ryzen 9 5950X 16-Core Processor”, which is exactly what will be communicated to the VM.

Result

When you have changed your vCPU type, restart your virtual machine and again issue the following command:

cat /proc/cpuinfo

Now it should give you a different output. In our case it shows this:

user@Ubuntu:~$ cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 25
model		: 33
model name	: AMD Ryzen 9 5950X 16-Core Processor
stepping	: 0
microcode	: 0xa201016
cpu MHz		: 3393.624
cache size	: 512 KB
physical id	: 0
siblings	: 8
core id		: 0
cpu cores	: 8
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 16
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core ssbd ibrs ibpb stibp vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr wbnoinvd arat npt nrip_save umip pku ospke vaes vpclmulqdq rdpid fsrm arch_capabilities
bugs		: sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 6787.24
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 48 bits physical, 48 bits virtual
power management:

As you can see when you look at the CPU “model name”, now it shows the actual host processor:

model name	: AMD Ryzen 9 5950X 16-Core Processor

Try your TensorFlow script again, now it should work!

By Leendert de Borst

Freelance software architect with 10+ years of experience. Expert in translating complex technical problems into creative & simple solutions.

Leave a comment

Your email address will not be published. Required fields are marked *