tensorflow encountered ImportError: Could not find'cudart64_100.dll' error resolution

When installing tensorflow, using import tensorflow, there was an error that the dll file could not be found. I consulted many blogs and stackflow solutions, and found that only the version number did not match, but did not specify what version is suitable Match the correct one, so write this guide to avoiding pits by hand. Thanks again to Brother Function for his guidance and help.
The author's environment:

python 版本3.6
tensorflow版本1.14
ImportError: Could not find 'cudart64_100.dll'

Short answer:

  1. Carefully analyze the type and cause of the error

  2. Find out your tensorflow and CUDA version

  3. Use the corresponding version to solve it, complete the adaptation of cuda and tf, the adaptation of cudnn and cuda, the adaptation of protobuf and tf

1. Reasons for the type of error

The problem is that the module of the dll file of the cuda system cannot be found, and it prompts that you need to download CUDA10.0, then first check whether the file exists in the path of cuda : access cuda
through the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDApath, and look for the cudart64_100.dllmodule in its bin directory.
If there is, then Check whether the environment variable is added; if not, it may be a matching problem between the cuda version and the tensorflow version

2. Find out your tensorflow and CUDA version

Enter the command line environment, first python --versionconfirm that your python version is 3.6
and then pip listcheck the installed tensorflow version. The author's own version is 1.14.
By nvcc --versionchecking the cuda version, the author's previous cuda version is V9.0.176;

Find the corresponding version information on the Tesnsorflow official website as follows:
Corresponding version information
You can see that when the Tensorflow version>=1.13, the CUDA version needs to be 10.0, and the cudnn version number needs to be greater than 7.4.1 ;
here I chose to uninstall the cuda version to apply tensorflow version
Directly enter the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDApath to delete the folder and delete the environment variable.
I found a server download link built by high school students. The download speed here will be faster:
tensorflow related download link

3. Match the corresponding cudnn corresponding cuda version

After installing the cuda version, I opened jupyter again import tensorflowand found that it was not successful, and 'cudnn64_7.dll'an error that could not be found appeared :

ImportError: Could not find 'cudnn64_7.dll'

This prompt indicates that the dll file of the cudnn module is missing. According to the tensorflow document, corresponding to tensorflow version 1.13 or higher, cudnn needs to be a version >7.4.1, download the cudnn version, and the directory structure of cudnn is as follows:
Insert picture description here
place the files in the cudnn directory correspondingly cuda directory

Four. Match the corresponding protobuf corresponding tf version

At this point, there should be no problem, I continued to run import tensorflow, MMP, did not run smoothly, a prompt 'descriptor'error appeared :

 ImportError: cannot import name 'descriptor'

Summary of tf installation problems on stackflow

Searching on stackflow, I found that the reason for the error is that the versions of protobuf and tf do not correspond, because there is a dependency between tf and pro, so I first uninstall pro, then uninstall tf, and finally reinstall tf, tf will automatically correct The dependency pro is installed.
There was a little episode in the middle. The author used the py virtual environment of virtualenv, so after installing the version, there will still be 'descriptor'errors, so I tested it in the native py environment and found that tf can be imported. Then the reason is that the system may not be able to find the sitepackage in the py virtual environment. Set the directory under the py-bin of the virtual environment as an environment variable to call it normally.
The final result is imported successfully:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_29027865/article/details/93236034