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

TensorFlow CPU版导入失败(DLL load failed),重装后仍异常求助

Fixing "DLL load failed" After Switching Back to TensorFlow CPU

Hey there, this kind of leftover clutter from a failed TensorFlow GPU install is really common—let’s walk through a thorough cleanup and reinstall to get your CPU version working again.

First, we need to make sure there’s no leftover GPU or broken CPU files hanging around:

  • Uninstall all TensorFlow variants via pip:
    pip uninstall -y tensorflow tensorflow-gpu tensorflow-estimator tensorflow-intel keras keras-core keras-preprocessing
    
  • Manually delete leftover folders in your Python environment’s Lib\site-packages directory. Look for folders named tensorflow, keras, keras_core, and any related subfolders—delete them all.
  • Clean up registry entries (Windows only):
    1. Open regedit via the Start Menu.
    2. Navigate to HKEY_CURRENT_USER\Software\Python\PythonCore\[Your Python Version]\Packages and delete any TensorFlow/Keras-related keys.
    3. Repeat the check in HKEY_LOCAL_MACHINE\Software\Python\PythonCore\[Your Python Version]\Packages (if present) and remove relevant entries. Be careful not to delete unrelated keys!

Step 2: Fix Dependencies and System Requirements

Most DLL failures stem from missing system components or incompatible dependencies:

  • Verify Python-TensorFlow compatibility: Double-check that your Python version matches the supported range for the TensorFlow CPU version you want to install. For example:
    • TensorFlow 2.15: Python 3.9–3.11
    • TensorFlow 2.16: Python 3.10–3.12
  • Install Visual C++ Redistributable: Download and install the latest Microsoft Visual C++ Redistributable for Visual Studio 2019-2022 (x64). This fixes 90% of missing DLL issues for TensorFlow.
  • Check for dependency conflicts: Run pip check in your terminal. If any packages are marked as conflicting, uninstall or update them to resolve the issues.

Step 3: Reinstall TensorFlow CPU Properly

Now let’s do a clean install:

  • First, upgrade pip to the latest version:
    python -m pip install --upgrade pip
    
  • Install the optimized TensorFlow CPU build (recommended):
    pip install tensorflow-intel
    
    Or install a specific stable version if you need it:
    pip install tensorflow==2.15.0
    
  • Verify the installation: Open a Python shell and run:
    import tensorflow as tf
    print(tf.__version__)
    print(tf.config.list_physical_devices('CPU'))
    
    If this runs without errors and shows your CPU device, you’re good to go!

The GPU install likely added CUDA/cuDNN paths to your system environment variables, which can interfere with the CPU version:

  • Right-click "This PC" → "Properties" → "Advanced system settings" → "Environment Variables".
  • In the "System variables" section:
    • Delete any variables named CUDA_PATH, CUDNN_PATH, or similar.
    • Remove any CUDA/cuDNN-related entries from the Path variable.
  • Restart your computer to apply these changes.

If you still run into issues after these steps, try creating a fresh virtual environment for TensorFlow—sometimes old environment conflicts are hard to fully clean up.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 07:04:14