You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python 3.6中无法导入TensorFlow求助(NVIDIA 940MX显卡)

Hey there, let's work through this TensorFlow import issue you're facing with your NVIDIA 940MX and Python 3.6 setup. From the package list you shared, you've got tensorflow-gpu 1.7.0 installed—but the critical missing pieces are the CUDA and cuDNN dependencies that TensorFlow's GPU version relies on. Here's a step-by-step fix tailored to your setup:

1. First, confirm your GPU's compatibility

Your NVIDIA 940MX uses the Maxwell architecture, which fully supports CUDA 9.0—this is the exact version required for TensorFlow 1.7.0. Avoid newer CUDA versions, as they won't play nice with your TF version.

2. Install CUDA Toolkit 9.0

Since CUDA 9.0 is a legacy version, you'll need to grab it from NVIDIA's archive:

  • Download the installer matching your OS (Windows/Linux/macOS) from NVIDIA's legacy CUDA downloads.
  • During installation, make sure to select the "CUDA" component (you can skip extras like GeForce Experience if you don't need them).
  • After installing, add the CUDA binaries to your system PATH to let Python find them:
    • Windows: Add C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin and C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp to your system PATH via Environment Variables.
    • Linux: Add these lines to your ~/.bashrc (or ~/.zshrc if you use Zsh):
      export PATH=/usr/local/cuda-9.0/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
      
      Then run source ~/.bashrc to apply changes.
    • macOS: Similar to Linux, add the paths to your shell profile (like ~/.bash_profile).
3. Install cuDNN 7.0.5 (matched to CUDA 9.0 and TF 1.7.0)

cuDNN is a GPU-accelerated library TensorFlow needs for deep learning operations. You'll need a free NVIDIA developer account to download it:

  • Grab cuDNN 7.0.5 for CUDA 9.0 from NVIDIA's cuDNN archive.
  • Extract the zip file, then copy the files into your CUDA directory:
    • Windows: Copy cuda/include/cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include; copy cuda/lib/x64/cudnn64_7.dll and cuda/lib/x64/cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64.
    • Linux: Copy cuda/include/cudnn.h to /usr/local/cuda-9.0/include; copy cuda/lib64/libcudnn*.so* to /usr/local/cuda-9.0/lib64. Then run:
      sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda-9.0/lib64/libcudnn*.so*
      
    • macOS: Copy the include and lib files to /usr/local/cuda/include and /usr/local/cuda/lib respectively.
4. Verify everything is set up correctly
  • Close and reopen your terminal/command prompt to ensure PATH changes take effect.
  • Run nvcc --version to confirm CUDA 9.0 is installed properly.
  • Now test TensorFlow in Python:
    import tensorflow as tf
    print(tf.__version__)
    print(tf.test.is_gpu_available())
    
    If is_gpu_available() returns True, you're all set!
5. Troubleshooting if it still fails
  • Windows DLL errors: Double-check that all CUDA and cuDNN DLLs are in your PATH, and confirm you're using a 64-bit Python 3.6 (TensorFlow 1.7 doesn't support 32-bit Python).
  • Linux driver issues: Make sure your NVIDIA drivers are up to date—they need to be version 384.81 or newer to work with CUDA 9.0.
  • Reinstall TensorFlow: If all else fails, try a clean reinstall:
    pip uninstall tensorflow-gpu -y
    pip install tensorflow-gpu==1.7.0
    

内容的提问来源于stack exchange,提问作者Hansa Tharuka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:43:09