Installing Tensorflow 2 gets a dll failed to load in pywrap_tensorflow.py

前端 未结 1 1315
夕颜
夕颜 2020-12-07 05:22

I have had problems here, here and there installing TensorFlow 2 over the last year or so. So I am trying Miniconda.

I have an AMD Radeon hd 6670 and an AMD Radeon hd

相关标签:
1条回答
  • 2020-12-07 05:33

    Status Quo

    I ran into a comparable problem (this is the furthest i got) reproducibly on two machines. Some of the discussed issues seems to be known for example here: 1 2 3 4. Not only to reproduce 2, it makes sense to also start using virtual environments in order to test multiple tf versions. This can be achieved like this: (link for virtualenv on windows)

    $ pip install --user pipenv
    

    Several things can be approached according to my knowledge.

    Checking the versions and compatibility

    As also commented on your other question, it is very important to pay attention to respectively fitting versions. I also talked about this in that answer. In which way did you install your python version(s) and anaconda? Because both user and system mode options are present on Windows (which you are assumably working on), which can interfere. To find that out, you can type these commands into the cmd: where anaconda and where python. This should output a list of found places in your system. If something is missing, you can also check PATH to see weather it was added there.

    Having corresponding versions is important - refer to here or here 2 as a starting point. Using the prebuilt wheels from the first link in this paragraph makes things easier as you just have to select the correct version and install it. The second link discusses the different combinations of tensorflow and python versions that are possible among other things.

    Another hint that could help when having multiple different versions (of python for example) is to always make sure to use the correct one. Calling the correct pip to install the respective wheel can then look like this in the cmd:

    C:\Users\XXXXX\AppData\Local\Programs\Python\Python38\Scripts\pip.exe install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.2.0-cp38-cp38-win_amd64.whl
    

    whereas the next command would give an error on my system after returning pip 20.1.1 from C:\Users\XXXXX\.conda\envs\tf-cpu-AVX-env\lib\site-packages\pip (python 3.7) (note the python version):

    pip.exe -V
    pip.exe install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.2.0-cp38-cp38-win_amd64.whl
    

    For these examples, the official prebuilt wheel from google would be used. Refer to this site where some recent tensorflow packages are presented. Note that this example is the wheel with neither GPU nor AVX. Because calling like this is error-prone and somewhat cumbersome, it is recommended to use the virtual environments as hinted in the beginning or the following:

    Using (ana)conda for Virtual Environments

    The virtual environments as said above dont just make it more convenient, but also more tightly organized. A good tool to do so is (ana)conda. For the anaconda gui, you can create a new venv under "environments" and set your python version to for example 3.5. Then you can search for the tensorflow package and install it very easily via the package list next to the environment list. You may of course have to install other packages as well, e.g. Pandas, scikit-learn, numpy.

    For use of Conda with the command line, this link provides a good help for the first steps (also from your other question mentioned above).

    Further reading on this topic (was about downgrading tf): here

    Checking for unmet dependencies

    For troubleshooting the "DLL load failed" problem on Windows systems, dependencies can be checked with this DLL dependency analyzer tool This comes from the link 4 from the beginning, leading to this post explanation on how to approach DLL load failed problems on Windows. With that, it was discovered on my system that this dynamic library was missing: api-ms-win-core-wow64-11-1-0.dll.

    Adressing Tensorflow CPU/GPU issues

    One of the possible sources for your trouble is incompatibilities with Tensorflow-GPU. This is because the default TF package contains both the CPU and GPU versions since the TF 2.1 release.

    To check if this causes some of your problems, a CPU-only variant can be tried first. You could for example try to install the correct tensorflow-CPU wheel from here (this is python 3.7 and tensorflow 2.0, decide weather to use AVX or not depending on the capabilities of your processor) or the google source named above.


    For Tensorflow-GPU, the following prerequisites have to be met:

    Installation of NVIDIA cuDNN (a GPU-accelerated library of primitives for deep neural networks) as e.g. cudnn-11.0-windows-x64-v8.0.1.13 here. After registration for the NVIDIA developer program, this can be accessed here.

    Please pay attention to the correct versions for a compatible CUDA Installation - see above! The current Tensorflow (2.2.0, but also true for TF ≥ 2.1.0 as of 23.07.2020) needs

    • CUDA 10.1 and the respective cuDNN ⤷ this is excactly matched only in the cuDNNv7.6.5 of November 5th, 2019, afaik.
    • For Cuda 10.1, a fitting NVIDIA® GPU driver of version 418.x or higher is required. This can be accessed e.g. here but has to be picked according to your platform. (Pay attention to not use a DCH driver where not applicable, see here.)
    • CUPTI, which ships with the CUDA Toolkit.
    • cuDNN SDK (>= 7.6)
    • (Optional) TensorRT 6.0 to improve latency and throughput for inference on some models.

    (This is partly taken from here)

    In order to install cuDNN (see above), the correct archive has to be downloaded, unzipped and copied from its directory the respective CUDA x.y install location. For windows, the locations for the three files are: (where x.y matches your specific installation as for example 10.2 - more information here and here)

    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.y\bin
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.y\include
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vx.y\lib
    

    Actually, not using the exact CUDA version 10.1 (but e.g. 10.2 instead) will cause errors such as: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

    To test your tensorflow configuration on AVX or GPU availability, you can use this approach.

    Using Tensorflow on your GPU

    I noticed, that you are using two AMD GPUs. I'm not aware of a port with OpenGL or something like this, as it is always talked about the CUDA Compute Capability (reference - it should be ≥3.5 for tensorflow and is only applicable for NVIDIA GPUs)

    Please refer to this answer (or probably also others) for solutions to problems related to missing CUDA support.

    Further reading on enabling the GPU for Tensorflow: here

    If all of the above doesn't help, another possible approach would be to build tensorflow from source by yourself (which could also lead to increased performance).

    0 讨论(0)
提交回复
热议问题