本文介绍了安装tensorflow(AVX支持)和cpuid python时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

导入错误:DLL 加载失败:动态链接库 (DLL) 初始化例程失败.

我去官方网站的错误页面,发现可能是 AVX 和 AVX2 指令集支持可能是问题,为了检查它,建议运行此代码:

from cpuid import *def _is_set(id, reg_idx, bit):regs = cpuid(id)if (1 <

但是当我尝试 pip install cpuid 时出现以下错误:

错误:需要 Microsoft Visual C++ 14.0

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

我假设未能找到 C++ 库"可能是导致这两个问题的原因.

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

如果您有任何想法如何解决或上述任何错误的原因可能是什么,请回复.

解决方案

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

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

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

2 tensorflow 的问题:

由于不支持 AVX,安装这个 wheel 将解决问题(也许有更新的可用).我有 tensorflow==2.2.0 并且效果很好.

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

警告 无法加载动态库cudart64_101.dll";dlerror: cudart64_101.dll 未找到

这是因为,tensorflow 软件包的较新版本(我不知道具体情况)带有 CPU 和 GPU 版本.如果你不想要 GPU 加速(像我一样)你可以忽略警告 查看此帖子了解更多信息.

现在一切运行完美!

注意:康达

如果您正在使用 anaconda,请确保所有版本的必需软件包(例如 numpy、...)都已更新!另外我在使用 https 时遇到了一些问题,复制 this 解决了问题.

While I was trying to setup tensorflow (both, using venv and without it) on import I got the following error:

I went to the official site's error page and found that possibly AVX and AVX2 instructions set support could be the issue, to check it, it was suggested to run this code:

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))

But when I tried to pip install cpuid I got the following Error:

I have already installed Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 (both x86, x64).

I assume that "failing to locate C++ libraries" could be the cause for both of these issues.

Also my CPU is Intel Pentium G4400 from 2015, and, from what I was able to find it DOES support AVX and AVX2, but I am unable to check it.

If you have any idea how to solve or what may be the cause for any of the mentioned errors above please respond.

解决方案

I've managed to resolve all the issues:

  1. Problem with cpuid and Microsoft Visual C++ 14.0 is required:

Now cpuid worked fine and it showed (using the provided code in the question) that AVX and AVX2 are NOT supported on my CPU!

2 Problem with tensorflow:

Now tensorflow will import but with one warning

This is because, newer versions(I do not know specifics) of tensorflow packages comes with both CPU and GPU versions. And if you do not want GPU accelerations (like me) you can ignore the warning see this post for more info.

Now everything runs perfectly!

if you are using anaconda make sure all versions of required packages (e.g. numpy, ...) are updated!Also I had some problems with https, copying this solved the issue.

这篇关于安装tensorflow(AVX支持)和cpuid python时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:46