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

Mac安装TensorFlow 1.13.1后导入报错求助:缺失libcublas.8.0.dylib

Fixing TensorFlow 1.13.1 ImportError: Missing libcublas.8.0.dylib on Mac

Hey there, let’s work through this TensorFlow import error you’re stuck with on your Mac. The root issue here is that TensorFlow can’t find the libcublas.8.0.dylib library, which is part of the CUDA toolkit required for GPU support. Here are some practical fixes to try out:

1. Switch to the CPU-only TensorFlow version (if you don’t have an NVIDIA GPU)

Most modern Macs use AMD or Apple Silicon GPUs, which aren’t supported by NVIDIA’s CUDA toolkit. If you don’t have an NVIDIA GPU, you probably installed the GPU-enabled variant of TensorFlow by mistake. Uninstall it and install the CPU-only version instead:

Using pip:

pip uninstall tensorflow-gpu
pip install tensorflow==1.13.1 --no-cache-dir

Using Anaconda:

conda uninstall tensorflow-gpu
conda install tensorflow==1.13.1

2. Install CUDA 8.0 and cuDNN 6.0 (if you have an NVIDIA GPU)

TensorFlow 1.13.1’s GPU version requires specific CUDA and cuDNN versions. The error mentions libcublas.8.0.dylib, which is part of CUDA 8.0. Here’s how to set this up:

  • Download and install the CUDA Toolkit 8.0 from NVIDIA’s archive (note: NVIDIA ended CUDA support for Mac after version 10.1, so 8.0 is the right match here for older NVIDIA-equipped Macs).
  • Download cuDNN 6.0 (compatible with CUDA 8.0), extract the files, and copy them into your CUDA installation directory (usually /usr/local/cuda-8.0/).
  • Add these environment variables to your shell config file (like ~/.bash_profile or ~/.zshrc):
    export CUDA_HOME=/usr/local/cuda-8.0
    export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
    export PATH=$CUDA_HOME/bin:$PATH
    
  • Restart your terminal and Jupyter Notebook to apply the changes.

3. Manually fix the rpath for the TensorFlow library

If you already have CUDA 8.0 installed but TensorFlow still can’t find the library, you can update the rpath (runtime library path) in the TensorFlow shared file using install_name_tool:

  • First confirm the location of libcublas.8.0.dylib (it should be at /usr/local/cuda-8.0/lib/libcublas.8.0.dylib if you installed CUDA correctly).
  • Run this command to add the correct rpath to the TensorFlow module:
    install_name_tool -add_rpath /usr/local/cuda-8.0/lib /Users/solomon/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
    

This is a quick workaround, so make sure your CUDA setup is correct first before trying this.

4. Verify your environment setup

After making changes, double-check that your environment variables are set properly:

  • In your terminal, run:
    echo $CUDA_HOME
    echo $LD_LIBRARY_PATH
    
  • In Jupyter Notebook, run this code to confirm the paths are available to Python:
    import os
    print(os.environ.get('CUDA_HOME'))
    print(os.environ.get('LD_LIBRARY_PATH'))
    

Hopefully one of these solutions gets TensorFlow importing correctly for you!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.12 05:03:59