[TOC]

I often encounter problems when installing Tensorflow-GPU. I have installed tensorflow-GPU several times myself, and I often encounter the same or similar problems. Therefore, I intend to record this and hope it can be helpful to others

The basic information

  • tensorflow-gpu
  • PIP installation (virtualenv and other virtual installation is also a PIP installation, but only a separate environment, does not affect the system environment, check the problem is easier, at most create a clean environment again)

After the installation, I will use the import tensorflow command to check whether the installation is successful.

ImportError: DLL load failed: Pywrap_tensorflow.py of the specified module cannot be found

Pywrap_xxx error message contains a large number of pywrap_xxx related scripts:

Traceback (most recent call last): File "E:\study\machinelearning\ENV\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "E:\study\machinelearning\ENV\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "E:\study\machinelearning\ENV\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "E:\study\machinelearning\ENV\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "E:\study\machinelearning\ENV\lib\imp.py", line 342, In load_dynamic return _load(spec) ImportError: DLL Load failed: the specified module cannot be found.Copy the code

This type of error occurs most frequently for several major reasons:

Microsoft Visual C++ 2013 Redistributable Update 3

This is my first time to install the encounter, download vc_redist. X64. Exe after the installation is OK

  • Regeneration of wave

When I installed it again today, I downloaded it and found it could not be installed. According to the log, my VS version is relatively new, so IT cannot be installed. Msvcp140.dll msvcp140.dll msvcp140.dll

  • Other Solutions

Some people say that you should install Redistributable with tensorFlow

After I installed the 2017 package again, and checked that THERE was msvCP140.DLL file in my system, I still reported the same error

(2) CUDA and CUDNN versions are inconsistent

This problem is also very numerous, I have installed cudA many times with almost no install failures, but encountered inconsistency with cudNN versions. Since the downloaded cuda defaults to the latest version of Cuda 10.0, and the cudNN I downloaded was the old one at the time, which was for Cuda 9.0, this was enough to fix the problem

  • Cuda download

By default, I click on my system configuration (Win10x64) and get the latest CUDa10-Win10, so I can click on Legacy Releases on the far right to see an earlier version

  • Cuda installation and verification

Exe (devicequery. exe) and bandwidthtest. exe (devicequery. exe)

  • Cudnn downloadTo log in to the Nvidia Developer accountClick on Archived cuDNN at the bottom to see more Releases, since I downloaded CUDA-9.0, and I’m on the safe side with cuDNN:Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0It makes sense hereDownload cuDNN v7.5.0 (Feb 21, 2019), for CUDA 9.0I think so. We’ll confirm it next time.

  • Cudnn installation

On the download page, you can open the Installation-Guide to see the CUDNN Installation Guide for Windows

(1) Copy the files under the bin, lib and include folders under the decompressed CUDNN to the cudA directory with the same name under the cudA installation directory: C: Program Files NVIDIA GPU Computing Toolkit CUDA V9.0

(2) Add CUDA paths to CUDA_PATH of the environment variableCuda books will add the cudA installation path to the environment variable path (Pay attention to: is at the front of the path, not easy to see), so don’t add CUDA paths to the path yourself

Here I put the decompressed cudnn on disk D, for example: d \cuda, and then put D:\cuda\bin in path, as some people online suggested. But the CUDN installation guide doesn’t mention it, so I don’t think it’s necessary

Unfortunately, today, after the guarantee of the version here has been, still quoted = =

(3) Tensorflow-GPU versions are inconsistent

Tensorflow-gpu installation with the default instruction:

pip install --upgrade tensorflow-gpu
Copy the code

The result is to install the latest version of Tensorflow-GPU. My version is as follows:

(1) Python: 3.6.0

(2) cuda – 9.0

(3) cudnn – 7.0

(4) tensorflow gpu — 1.13.0

The latest CUDA is 10.0, but I installed 9.0, so I loaded tensorflow-GPU to 1.12.0, and it worked out perfectly. ^_^

PIP uninstall tensorflow-gpu==1.13.0 PIP install tensorflow-gpu==1.12.0Copy the code

Tensorflow-gpu1.13.0 is a copy of the latest CUDA release.

If, like me, all of the above problems are solved, check to see if this version is too new or too old. There was an interlude because I started accidentally typing 1.12.0 instead of 1.2.0, and it still didn’t work, so it was a waste of time.

(4) Other Python library versions, etc

Some people on the web have problems with python library versions such as Numpy, but I don’t, because I download all the dependencies when I install tensorflW-GPU

TensorFlow PIP installation issue: cannot import name ‘Descriptor’ graph_pb2.py

Error message for graph_xxx:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "F:\study\machinelearning\ENV\lib\site-packages\tensorflow\__init__.py", line 24, in <module> from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "F:\study\machinelearning\ENV\lib\site-packages\tensorflow\python\__init__.py", line 59, in <module> from tensorflow.core.framework.graph_pb2 import * File "F:\study\machinelearning\ENV\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module> from google.protobuf import descriptor as _descriptor File "F:\study\machinelearning\ENV\lib\site-packages\google\protobuf\descriptor.py", line 47, In <module> from google.protobuf.pyext import _message ImportError: DLL load failed: The specified program cannot be found.Copy the code

I encountered this twice, both times because the version of protobuf was too high, the same thing I found on the Internet, it was fixed by lowering the version of protobuf from 3.6.1 to 3.6.0

PIP list PIP uninstall protobuf install protobuf==3.6.0 PIP listCopy the code

reference

[1]import error: load dll failed