PyCharm中无法导入TensorFlow-gpu 1.8.0的问题求助
cudnn64_7.dll Not Found in PyCharm with Anaconda Interpreter Hey there, since you’ve confirmed the issue only pops up with your Anaconda-based PyCharm interpreter (and works fine in CMD/another non-Anaconda user account), let’s walk through targeted fixes to get this sorted:
1. Verify PyCharm’s Interpreter Environment Variables
PyCharm might not be pulling in the system PATH for your Anaconda interpreter. Here’s how to check and adjust it:
- Open PyCharm, navigate to File > Settings > Project: [Your Project Name] > Python Interpreter
- Click the gear icon ⚙️ next to the interpreter dropdown, select Show All
- Locate your Anaconda interpreter (e.g.,
Python 3.6 (base: conda)), click the pencil icon ✏️ to edit its settings - Switch to the Environment Variables tab
- Look for the
PATHvariable: if your cuDNNbindirectory (wherecudnn64_7.dllis stored) isn’t listed, click the + button to add it:- Variable name:
PATH - Variable value: Paste your cuDNN bin path (e.g.,
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUDNN\v7.0\bin) followed by a semicolon;and the existing PATH value
- Variable name:
- Save changes, restart PyCharm, and test importing TensorFlow again.
2. Fix Anaconda’s Environment PATH Overrides
Anaconda sometimes resets the PATH when activating an environment, which can hide your system’s cuDNN path. Try this:
- Open PyCharm’s built-in Terminal (bottom panel)
- Run
echo %PATH%and check if your cuDNN bin directory is present in the output - If it’s missing, open Anaconda Prompt, activate your environment with
conda activate [your_env_name], then run:conda env config vars set PATH="C:\your\cudnn\bin\path;%PATH%" - Restart PyCharm and reactivate the environment in the terminal to apply changes.
3. Quick Workaround: Copy the DLL to Anaconda’s Library Folder
As a straightforward fix, copy cudnn64_7.dll from its current location to the Library\bin folder of your Anaconda environment:
- For the base environment:
C:\Users\[Your Username]\Anaconda3\Library\bin - For a custom environment:
C:\Users\[Your Username]\Anaconda3\envs\[Your Env Name]\Library\bin
This ensures the Anaconda interpreter can find the DLL directly without relying on PATH configurations.
4. Create a Clean Anaconda Environment
If your current environment has conflicting packages or broken PATH settings, start fresh with a dedicated environment:
- Open Anaconda Prompt and create a new environment (TensorFlow 1.8.0 works best with Python 3.6):
conda create -n tf_gpu_env python=3.6 - Activate the environment:
conda activate tf_gpu_env - Install TensorFlow-GPU 1.8.0:
pip install tensorflow-gpu==1.8.0 - Back in PyCharm, switch your project interpreter to this new
tf_gpu_envenvironment, then test importing TensorFlow.
内容的提问来源于stack exchange,提问作者GuPe

