无法从PyCharm导入TensorFlow

时间:2018-05-11 16:16:11

标签: python tensorflow pycharm

我按照TF和NVIDIA网站上的说明安装了CUDA 9.0和cuDNN 7.0后,从PyCharm软件包管理器下载并安装了TensorFlow 1.8.0和TensorFlow-gpu 1.8.0,以便我可以使用笔记本电脑的GPU。但是,每当我尝试从PyCharm导入TensorFlow时,它都会抛出以下错误:

ImportError: Could not find 'cudnn64_7.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 7 from this URL: https://developer.nvidia.com/cudnn

包含cudnn64_7.dll的目录确实在PATH环境变量中。我是PyCharm的新手,但我在另一篇文章中读到,添加PyCharm环境变量的路径可能是问题,所以我试过了:

enter image description here

但这也不起作用。我知道所有的库和依赖项都在工作,因为我可以从命令提示符中导入TensorFlow。事实上,在我的计算机中,我创建了一个不同的用户帐户,并在那里使用PyCharm导入TensorFlow,再一次它工作正常。我怀疑它与我的PyCharm正在使用的解释器有关,因为这是两个用户帐户之间的唯一区别。在我以前没有安装Anaconda3的用户帐户上,而在我没有工作的用户帐户上,其各自的PyCharm正在使用位于Anaconda3文件中的解释器。我怎样才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

转到cuDNN存档https://developer.nvidia.com/rdp/cudnn-archive

单击“为CUDA 9.0下载cuDNN v7.6.1(2019年6月24日)”

点击操作系统的版本

解压缩。应该提取到名为cuda的目录

复制文件夹的内容

将其粘贴到“ C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v9.0”

全部完成!!