简体   繁体   中英

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. However, whenever I try to import TensorFlow from PyCharm, it throws the following error:

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. 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:

在此处输入图片说明

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. In fact, within my computer, I made a different user account and used PyCharm there to import TensorFlow and once again it worked fine. 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. 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. How can I fix this?

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

Click on "Download cuDNN v7.6.1 (June 24, 2019), for CUDA 9.0"

Click on the version fro your operating system

Unzip. Should extract to a directory called cuda

Copy the contents of the folder

paste it to "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0"

All done!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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