简体   繁体   English

无法从PyCharm导入TensorFlow

[英]Cannot import TensorFlow from PyCharm

I downloaded and installed TensorFlow 1.8.0 and TensorFlow-gpu 1.8.0 from the PyCharm package manager after installing CUDA 9.0 and cuDNN 7.0 as was instructed on the TF and NVIDIA websites so that I could use my laptop's GPU. 按照TF和NVIDIA网站上的指示安装CUDA 9.0和cuDNN 7.0后,我从PyCharm软件包管理器下载并安装了TensorFlow 1.8.0和TensorFlow-gpu 1.8.0,以便可以使用笔记本电脑的GPU。 However, whenever I try to import TensorFlow from PyCharm, it throws the following error: 但是,每当我尝试从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

The directory containing cudnn64_7.dll is indeed in the PATH environment variable. 包含cudnn64_7.dll的目录确实在PATH环境变量中。 I am new to PyCharm, but I read on another post that adding the path to PyCharm's environment variable could be the problem, so I tried that: 我是PyCharm的新手,但我在另一篇文章中读到,将路径添加到PyCharm的环境变量可能是问题所在,因此我尝试这样做:

在此处输入图片说明

But this did not work either. 但这也不起作用。 I know all of the libraries and dependencies are working because I can import TensorFlow just fine from the command prompt. 我知道所有库和依赖项都在工作,因为我可以从命令提示符下导入TensorFlow。 In fact, within my computer, I made a different user account and used PyCharm there to import TensorFlow and once again it worked fine. 实际上,在我的计算机中,我创建了一个不同的用户帐户,并在那里使用PyCharm导入TensorFlow,并且它再次运行正常。 I suspect it has something to do with the interpreter that my PyCharm is using, because that is the only difference between the two user accounts. 我怀疑这与我的PyCharm使用的解释器有关,因为这是两个用户帐户之间的唯一区别。 On the user account that works I had not previously installed Anaconda3, whereas on the user account that does not work I had, and its respective PyCharm is using the interpreter located in an Anaconda3 file. 在可以正常工作的用户帐户上,我以前没有安装Anaconda3,而在不能正常工作的用户帐户上,我已经安装了它,相应的PyCharm正在使用Anaconda3文件中的解释器。 How can I fix this? 我怎样才能解决这个问题?

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

Click on "Download cuDNN v7.6.1 (June 24, 2019), for CUDA 9.0" 单击“为CUDA 9.0下载cuDNN v7.6.1(2019年6月24日)”

Click on the version fro your operating system 单击您操作系统的版本

Unzip. 解压缩。 Should extract to a directory called cuda 应该提取到名为cuda的目录

Copy the contents of the folder 复制文件夹的内容

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

All done!!! 全部做完!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM