未检测到 Tensorflow GPU:Centos

Tensorflow GPU Not detected : Centos

我曾经在tensorflow中使用多GPU系统。

然而,从某一天开始,以下代码只使用 CPU。

tf.debugging.set_log_device_placement(True)
strategy = tf.distribute.MirroredStrategy()

另外,物理设备检查功能return为空

tf.config.list_physical_devices('GPU')

nvidia-smi的return正确显示如下图

环境 NVIDIA_SMI: 418.87.00

驱动程序版本:418.87.00

CUDA 版本:10.1

张量流:2.4.1

CuDNN:

我该如何处理这个问题?

你对生态系统有什么改动吗

我建议你安装 cuda 11 和 cudnn 8.0 以及 tensorflow 2.4.0 及以上版本。

那就试试吧。希望你的问题得到解决。

Tensorflow 2.4 与 cudnn v8.0cuda 11.

兼容

所以,升级cuddn和cuda

如果您没有使用 Anaconda,请更新系统路径并确保它们不是任何以前的版本。

例如,

/usr/local/cuda/bin/nvcc --version

康达安装:

# conda update --force conda ## if needed
# conda update conda ## if needed
conda activate <env>
conda install cudatoolkit
conda install -c anaconda cudnn
conda list cuda
conda list cudnn

这是一个用于手动安装的脚本/即使使用 conda 也可能需要:

wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt-get update

# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
    cuda-11-0 \
    libcudnn8=8.0.4.30-1+cuda11.0  \
    libcudnn8-dev=8.0.4.30-1+cuda11.0


# Install TensorRT. Requires that libcudnn8 is installed above.
sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0 \
    libnvinfer-dev=7.1.3-1+cuda11.0 \
    libnvinfer-plugin7=7.1.3-1+cuda11.0