我正在尝试将 Tensorflow 与我的 GPU 结合使用。我的系统是 Fedora Linux 38,NVIDIA 驱动程序 535.113.01(当前最新)在我的系统上按预期工作。
我使用 Python 3.9 创建了一个 Python 环境(据我所知版本 3.11 无法使用 pip 安装 TF 2.14.0)。
在激活的环境中我安装TF如下:
python3.9 -m pip install tensorflow[and-cuda]
我可以看到 pip 安装了 Tensoflow 和许多必需的库(cublas、cuda、cull 等)。
一切看起来都不错,但是当我导入tensorflow时,我收到此错误:
>>> import tensorflow as tf 2023-10-22 01:58:31.798579: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2023-10-22 01:58:31.798611: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2023-10-22 01:58:31.798638: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2023-10-22 01:58:31.804107: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
然后我使用 Tensorflow 中的 docker 镜像:tensorflow/tensorflow:latest-gpu,作为最后一个选项,但这显示了完全相同的错误
其他信息
Python 版本:版本应 >=3.9 且 < 3.11 (I tried with many versions in between)
没有本地安装 CUDA/CUdNN:我删除了 CUDA 和 CUdNN,使用“find / -iname cuda”来确保没有痕迹
我重新安装了驱动程序并尝试了520版本,同样的问题
我试图弄清楚发生了什么,当 Tensorflow 说“...一个已经在 2023 年 10 月 22 日注册”为 cuDNN、cuBLAS、cuFFT 时,以便能够理解至少要查找什么,但我在网上找不到任何有用的东西。
经过72个小时的反复尝试,但没有成功,包括重新安装各个版本的nvidia驱动程序,我重新安装了操作系统并遵循了流程:
现在导入 Tensorflow,虽然显示相同的警告,但将使用 GPU:
physical_devices = tf.config.experimental.list_physical_devices('GPU')
if len(physical_devices) > 0:
print("We got a GPU")
tf.config.experimental.set_memory_growth(physical_devices[0], True)
else:
print("Sorry, no GPU for you...")
这表明我的 GPU 终于启动并运行了……现在我可以再花 72 小时处理数据了……