【问题标题】:Error while installing tensorflow(AVX support) and cpuid python安装 tensorflow(AVX 支持)和 cpuid python 时出错
【发布时间】:2020-11-15 11:55:09
【问题描述】:

当我尝试在 import 上设置 tensorflow(使用和不使用 venv)时,出现以下错误:

ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

我去官网的错误页面,发现可能是AVX和AVX2指令集支持问题,检查一下,建议运行这段代码:

from cpuid import *

def _is_set(id, reg_idx, bit):
    regs = cpuid(id)

    if (1 << bit) & regs[reg_idx]:
        return "Yes"
    else:
        return "--"

print("Vendor ID         : %s" % cpu_vendor())
print("CPU name          : %s" % cpu_name())
print("Microarchitecture : %s%s" % cpu_microarchitecture())
print("Vector instructions supported:")
print("SSE       : %s" % _is_set(1, 3, 25))
print("SSE2      : %s" % _is_set(1, 3, 26))
print("SSE3      : %s" % _is_set(1, 2, 0))
print("SSSE3     : %s" % _is_set(1, 2, 9))
print("SSE4.1    : %s" % _is_set(1, 2, 19))
print("SSE4.2    : %s" % _is_set(1, 2, 20))
print("SSE4a     : %s" % _is_set(0x80000001, 2, 6))
print("AVX       : %s" % _is_set(1, 2, 28))
print("AVX2      : %s" % _is_set(7, 1, 5))
print("BMI1      : %s" % _is_set(7, 1, 3))
print("BMI2      : %s" % _is_set(7, 1, 8))

但是当我尝试pip install cpuid 时,我得到了以下错误:

错误:需要 Microsoft Visual C++ 14.0

我已经安装了Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019(x86、x64)。

我认为“未能找到 C++ 库”可能是导致这两个问题的原因。

另外,我的 CPU 是 2015 年的 Intel Pentium G4400,据我所知,它确实支持 AVX 和 AVX2,但我无法检查。

如果您知道如何解决或可能导致上述任何错误的原因,请回复。

【问题讨论】:

  • 您能分享一下您的 CPU 品牌和型号吗?
  • 我写的,但是格式不正确,是Intel Pentium G4400 @3.30GHz

标签: python tensorflow


【解决方案1】:

我已经设法解决了所有问题:

  1. cpuid 存在问题,需要 Microsoft Visual C++ 14.0:

VS BuildTools needed,我安装了所有标记的项目,但后来我发现显然只需要 Windows 10 SDK。

现在cpuid 工作正常,它显示(使用问题中提供的代码)我的 CPU 不支持 AVX 和 AVX2!

2 tensorflow 的问题:

由于不支持 AVX,安装此 wheel 将解决问题(可能有更新的可用)。我有tensorflow==2.2.0,它运行良好。

现在tensorflow 将导入但有一个警告

警告Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

这是因为,tensorflow 软件包的较新版本(我不知道具体情况)带有 CPU 和 GPU 版本。如果你不想要 GPU 加速(像我一样),你可以忽略警告 see this post for more info

现在一切运行完美!

注意:康达

如果您使用anaconda,请确保所需软件包的所有版本(例如numpy,...)都已更新! 我也遇到了https的一些问题,复制this解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 2020-04-18
    • 2023-01-31
    • 2015-03-01
    • 2020-10-26
    • 2021-12-25
    相关资源
    最近更新 更多