如何在 Ubuntu 20.04 64 位的 VirtualBox 6.1.16 中启用 AVX / AVX2?

Som*_*ing 12 virtualbox virtual-machine avx avx2 tensorflow

长话短说:

  • 当通过 Python 导入时,Tensorflow 1.15 在我的虚拟机上崩溃(错误消息是Illegal instruction (core dumped)),很可能是由于 AVX 和 AVX2 被禁用。
  • 我的主机(Windows 10 64 位)具有AVX 和 AVX2(使用 Cygwin 进行验证,请参阅下面的更多详细信息)[CPU 是 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz]
  • 在客户机上(使用 VirtualBox 6.1.16 的 Ubuntu 20.04 64 位,18.04 也会发生同样的情况),缺少 AVX 和 AVX2。
  • 根据现有线程的建议,我在主机上运行并重新启动了来宾机 - 没有任何变化(来宾机的名称是 Ubuntu20)VBoxManage setextradata "Ubuntu20" VBoxInternal/CPUM/IsaExts/AVX 1VBoxManage setextradata "Ubuntu20" VBoxInternal/CPUM/IsaExts/AVX2 1

有什么建议吗?

更多细节:

cat /proc/cpuinfo使用 Cygwin 在主机上的输出- 它在 avx2 中有 avx:

.....
processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
stepping        : 9
cpu MHz         : 3600.000
cache size      : 256 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts
 acpi mmx fxsr sse sse2 ss ht tm pbe pni dtes64 est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 movbe 
popcnt aes xsave osxsave avx f16c rdrand hypervisor lahf_lm ida xsaveopt pln pts dtherm fsgsbase 
tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt
TLB size        : 0 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:
Run Code Online (Sandbox Code Playgroud)

来宾计算机上的输出cat /proc/cpuinfo- avx 和 avx2 丢失:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 158
model name  : Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
stepping    : 9
microcode   : 0xffffffff
cpu MHz     : 3599.996
cache size  : 8192 KB
physical id : 0
siblings    : 1
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 22
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 rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid 
tsc_known_freq pni ssse3 pcid sse4_1 sse4_2 hypervisor lahf_lm invpcid_single pti fsgsbase invpcid 
md_clear flush_l1d arch_capabilities
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips    : 7199.99
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:
Run Code Online (Sandbox Code Playgroud)

Pat*_*aña 14

正如@George-Zheng提到的,如果您看到海龟图标,则说明您已启用 Hyper-V。按照他提供的链接上的建议可以解决此问题,您会注意到这一点,因为海龟现在变成了带有 V 的芯片。

总结一下说明:

  1. 以管理员身份在 Windows 主机中打开命令提示符。

    • 找到命令提示符图标并右键单击。选择以管理员身份运行。
  2. 禁用管理程序午餐

    bcdedit /set hypervisorlaunchtype off

  3. 禁用 Microsoft Hyper-V

    DISM /Online /Disable-Feature:Microsoft-Hyper-V

  4. 关机快 shutdown -s -t 2

  5. 等待几秒钟再打开。

如果问题仍然存在,请再坚持一两次。第二次对我有用。

  • 谢谢你,解决了这个问题,现在运行得好多了,而且没有收到 SIGILL。一般建议可能应该是 1. 重新启动 PC 并且不要打开任何 VM 应用程序,2. 按照步骤禁用 Hyper-V (2认同)