Objective:
TensorFlow has two versions of CPU and GPU: GPU version requires NVIDIA Cuda and CuDNN support, CPU version is not required; This article mainly installs the GPU version.
1. Environment
- GPU: Verify that your video card supports CUDA, which is confirmed here.
- VS2015 Runtime Library: Download 64-bit, download here, install after download.
- Python 3.6/3.5: Download 64-bit, download here, install after download.
- Pip 9.0.1 (confirm pip version >= 8.1, use pip-v to view the current PIP version, and upgrade Pip with python-m pip install-u pip. )
Note: Pip actually comes in when you install Python, but it needs to be (xxx:\ python\python36\scripts) is configured in the environment variable (path), the red font represents the path to the Python installation.
2. Installation
(1), download CUDA
Google official recommended CUDA8, can go to the official website download: Cuda
Directly double-click the EXE installation, follow the prompts to install the end of the line. After the test is installed, the command line enters Nvcc-v and the version information indicates that the installation was successful.
(2), download CUDNN
TensorFlow version different, the need for the CUDNN version is not the same, see TensorFlow release notes, such as: tensorflow1.3 Release Notes
Download to the corresponding version of CUDNN (tensorflow1.3 need cuDNN6, can be downloaded to https://www.zhihu.com/question/37082272), unzip:
- The extracted bin directory is configured into the system environment variable (path);
- Copy the appropriate files to the appropriate directory:
Copy Cudnn\bin\cudnn64_5.dll to C:\Program files\nvidia GPU Computing toolkit\cuda\v8.0\bin\
Copy Cudnn\include\cudnn.h to C:\Program files\nvidia GPU Computing toolkit\cuda\v8.0\include\
Copy Cudnn\lib\x64\cudnn.lib to C:\Program files\nvidia GPU Computing toolkit\cuda\v8.0\lib\x64\
(3), installation TensorFlow
[HTML]View PlainCopy
- # GPU Version
- PIP3 Install--upgrade Tensorflow-gpu
- # CPU Version
- PIP3 Install--upgrade TensorFlow
(4), uninstall TensorFlow
[HTML]View PlainCopy
- PIP3 Uninstall TensorFlow
3. Testing
[HTML]View PlainCopy
- Import TensorFlow as TF
- A = Tf.random_normal ((+))
- b = Tf.random_normal ((+, +))
- c = Tf.matmul (A, b)
- Sess = TF. InteractiveSession ()
- Sess.run (c)
Issue
[HTML]View PlainCopy
- Traceback (most recent):
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line +, in Swig_import_helper
- Return Importlib.import_module (Mname)
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in Import_module
- Return _bootstrap._gcd_import (name[level:], package, level)
- File "<frozen Importlib._bootstrap>", line 986, in _gcd_import
- File "<frozen Importlib._bootstrap>", Line 969, in _find_and_load
- File "<frozen Importlib._bootstrap>", Line 958, in _find_and_load_unlocked
- File "<frozen Importlib._bootstrap>", Line 666, in _load_unlocked
- File "<frozen Importlib._bootstrap>", Line 577, in Module_from_spec
- File "<frozen importlib._bootstrap_external>", Line 906, in Create_module
- File "<frozen Importlib._bootstrap>", Line 222, in _call_with_frames_removed
- Importerror:dll load failed:the specified module could not be found.
- During handling of the above exception, another exception occurred:
- Traceback (most recent):
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow.py ", line $, in <module>
- From tensorflow.python.pywrap_tensorflow_internal Import *
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line +, in <module>
- _pywrap_tensorflow_internal = swig_import_helper ()
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line A, in Swig_import_helper
- Return Importlib.import_module (' _pywrap_tensorflow_internal ')
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in Import_module
- Return _bootstrap._gcd_import (name[level:], package, level)
- Importerror:no module named ' _pywrap_tensorflow_internal '
- During handling of the above exception, another exception occurred:
- Traceback (most recent):
- File "<pyshell#0>", Line 1, in <module>
- Import TensorFlow as TF
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line +, in <module>
- From Tensorflow.python Import *
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", Line Wuyi, in <module>
- From Tensorflow.python import Pywrap_tensorflow
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow.py ", line-in <module>
- Raise Importerror (MSG)
- Importerror:traceback (most recent):
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line +, in Swig_import_helper
- Return Importlib.import_module (Mname)
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in Import_module
- Return _bootstrap._gcd_import (name[level:], package, level)
- File "<frozen Importlib._bootstrap>", line 986, in _gcd_import
- File "<frozen Importlib._bootstrap>", Line 969, in _find_and_load
- File "<frozen Importlib._bootstrap>", Line 958, in _find_and_load_unlocked
- File "<frozen Importlib._bootstrap>", Line 666, in _load_unlocked
- File "<frozen Importlib._bootstrap>", Line 577, in Module_from_spec
- File "<frozen importlib._bootstrap_external>", Line 906, in Create_module
- File "<frozen Importlib._bootstrap>", Line 222, in _call_with_frames_removed
- Importerror:dll load failed:the specified module could not be found.
- During handling of the above exception, another exception occurred:
- Traceback (most recent):
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow.py ", line $, in <module>
- From tensorflow.python.pywrap_tensorflow_internal Import *
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line +, in <module>
- _pywrap_tensorflow_internal = swig_import_helper ()
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py ", line A, in Swig_import_helper
- Return Importlib.import_module (' _pywrap_tensorflow_internal ')
- File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in Import_module
- Return _bootstrap._gcd_import (name[level:], package, level)
- Importerror:no module named ' _pywrap_tensorflow_internal '
- Failed to load the native TensorFlow runtime.
- See Https://www.tensorflow.org/install/install_sources#common_installation_problems
- For some common reasons and solutions. Include the entire stack trace
- Above this error message is asking for help.
If the
Import TensorFlowWhen this problem occurs, it is most likely that the corresponding VS runtime library, such as tensorflow1.3, is not installed, and the runtime library that requires vs2015 is Visual C + + Redistributable for Visual Studio 2015
WINDOWS10 Installing the TensorFlow GPU version (PIP3 installation method)