这是从链接上的以下问题扩展的问题:
python : cannot import tensorflow-gpu
我正在尝试在我的Windows 10机器上实现tensorflow-gpu。我跟着这个link告诉我做的事情。我有..
>conda create -n tensorflow-gpu python=3.5.2
>activate tensorflow-gpu
>pip install tensorflow-gpu
>activate tensorflow-gpu
(tensorflow-gpu) >python
>>>
但是,如果我尝试导入tensorflow,
>>>import tensorflow as tf
我收到以下错误消息
Traceback (most recent call last):
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\site-
packages\tensorflow\python\platform\self_check.py", line 87, in preload_check
ctypes.WinDLL(build_info.cudnn_dll_name)
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\ctypes\__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] This specified module could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
self_check.preload_check()
File "C:\Users\Froilan\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\platform\self_check.py", line 97, in preload_check
% (build_info.cudnn_dll_name, build_info.cudnn_version_number))
ImportError: Could not find 'cudnn64_6.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 6 from this URL: https://developer.nvidia.com/cudnn
我不确定是什么导致了这个问题。我正在使用AMD ryzen 1700 CPU和GTX 1050 Ti GPU。也许其中一个导致了这个问题?
更新:与CPU的tensorflow工作正常。带GPU的那个是导致问题的原因
conda install -c anaconda tensorflow-gpu
cuda toolkit
和cudnn
并完成所有配置cudnn
变量中添加PATH
路径export PATH
或者去.bashrc
and设置PATH变量我相信使用命令
pip install tensorflow-gpu
安装最新版本的TensorFlow,目前大概是1.6。根据我的经验,最新版本似乎只适用于CUDA 9.0,后者又需要cuDNN 7.0.4或7.0.5。您可以使用此命令安装可与CUDA 8.0一起使用的特定版本的TensorFlow:
pip install tensorflow-gpu==1.4
或者,您可以从NVIDIA下载旧版本的CUDA和cuDNN。要做到这一点,你必须先创建一个帐户(不要担心,它是免费的,非常快)。
旧版本的CUDA在这里:https://developer.nvidia.com/cuda-toolkit-archive
旧版本的cuDNN:https://developer.nvidia.com/rdp/cudnn-download
TensorFlow网站可以更新,因为它仍然告诉你安装CUDA 8.0,但我认为只适用于TensorFlow版本1.4。
你的问题是tensorflow
正在寻找cudnn v6
。 tensorflow 1.4
与CUDA 8.0
和CUDNN 6
合作。默认情况下,pip将安装tensorflow 1.5/1.6
,这需要在Windows上使用CUDA 9.0
和CUDNN 6.0
。检查要求here。根据我的经验,错误的子版本(即6.1)也会导致问题。