Error while installing tensorflow(AVX support) and cpuid python

0

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

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

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:

error: Microsoft Visual C++ 14.0 is required

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.

python
tensorflow
asked on Stack Overflow Jul 25, 2020 by kaktus_car • edited Jul 25, 2020 by kaktus_car

1 Answer

1

I've managed to resolve all the issues:

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

VS BuildTools needed, I installed all the marked items but I found out later that apparently only Windows 10 SDK is needed.

enter image description here

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

enter image description here

2 Problem with tensorflow:

Since AVX is not supported, installing this wheel will solve the problem (maybe newer is available). I have tensorflow==2.2.0 and it works perfectly.

Now tensorflow will import but with one warning

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

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!

NOTE: Conda

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.

answered on Stack Overflow Jul 25, 2020 by kaktus_car • edited Jul 25, 2020 by kaktus_car

User contributions licensed under CC BY-SA 3.0