Win10下Python3.6安装tensorflow-gpu总结
1 安装工具(Anaconda)
网络上各种安装Python库的方式。经过本人实践,最方便的方式还是用Anaconda安装。安装指令也很简单。
在CMD界面中输入:conda install * (* 为对应库名),例如conda install numpy.
2 CUDA 和cudnn选择
Python3.6版本需用CUDA8.0和cudnn6.切记
不然导入错误:
importtensorflow as tf
Traceback (most recent call last):
File "D:\ProgramFiles\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Program Files\Python35\lib\importlib\__init__.py",line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in_gcd_import
File "", line 969, in_find_and_load
File "", line 958, in_find_and_load_unlocked
File "", line 666, in_load_unlocked
File "", line 577, inmodule_from_spec
File "", line 906,in create_module
File "", line 222, in_call_with_frames_removed
ImportError: DLL load failed: 找不到指定的模块。
Duringhandling of the above exception, another exception occurred:
Traceback(most recent call last):
File "D:\ProgramFiles\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Program Files\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\ProgramFiles\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 20, in swig_import_helper
returnimportlib.import_module('_pywrap_tensorflow_internal')
File "D:\Program Files\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'
Duringhandling of the above exception, another exception occurred:
3 安装TensorFlow-GPU
Python3.6 对应的Tensorflow-gpu需要1.3.0以上版本。
可用三种方式安装:
A: pip installtensorflow-gpu
B : pip install *.whl
C : 已经安装过tensorflow的建议用如下指令升级
pip3 install –ignore-installed –upgrade tensorflow-gpu
将会安装最新版本tensorflow.
笔者走过弯路,先用的清华的镜像,安装的低版本,然后用的C方式进行了升级。
安装完成后,依次在控制台输入:
cmd->python->import tensorflow as tf
无报错,则成功。