Tensorflow 在 GPU 上花费太多时间

Tensorflow Taking too much time on GPU

import tensorflow as tf

gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
    print("Name:", gpu.name, "  Type:", gpu.device_type)

from tensorflow.python.client import device_lib
device_lib.list_local_devices()
 

tf.test.is_gpu_available()

我能够得到 True 的输出(即 Tensorflow 能够检测到 GPU),但问题是它需要 5 - 10 分钟才能显示输出并不断消耗系统内存。我将 RTX 3060Ti 与 Python 3.8、CUDA 10.1、cudnn 7.6、tensorflow 2.3.1 和 tensorflow-gpu 2.3.1 一起使用。

这是因为Tensorflow 2.3版本不支持使用CUDA 11,但所有Ampere卡至少需要CUDA 11.0和Cudnn 8。

幸运的是 TensorFlow 2.4 最近发布了。它兼容,但 CUDA 11.0 略低。

请从 Nvidia 网站的档案部分更新您的安装以使用 CUDA 11.0。它的性能不如 11.1(这是第一个正式支持 RTX 3000 的版本),但至少它会支持 Ampere GPU

您可以从 here.

轻松查看用于构建 Tensorflow 的 CUDA 和 cuDNN 版本