Tensorflow 2.4.0无法打开某些GPU库

sq1bmfud  于 2023-02-13  发布在  其他
关注(0)|答案(1)|浏览(147)

我的cuda是11.0,我有pip安装这个。

python install tensorflow==2.4.0

输入后

import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus, cpus)

明白了

[] [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
2023-02-01 19:23:13.355591: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2023-02-01 19:23:13.357538: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:af:00.0 name: A100-PCIE-40GB computeCapability: 8.0
coreClock: 1.41GHz coreCount: 108 deviceMemorySize: 39.59GiB deviceMemoryBandwidth: 1.41TiB/s
2023-02-01 19:23:13.357678: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2023-02-01 19:23:13.357726: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2023-02-01 19:23:13.357743: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2023-02-01 19:23:13.357758: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2023-02-01 19:23:13.357773: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2023-02-01 19:23:13.357919: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory
2023-02-01 19:23:13.357955: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2023-02-01 19:23:13.357970: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2023-02-01 19:23:13.357978: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

如何解决这个问题?谢谢。

mqkwyuun

mqkwyuun1#

python install tensorflow==2.4.0不是安装tensorflow的正确代码。
安装python之后,您可以使用pip命令或conda命令(如果您安装了conda软件)在系统中安装tensorflow。

在conda环境中使用pipconda安装张流。

  • 在系统中安装anaconda/Miniconda后,打开anaconda命令提示符
  • 创建一个conda VirEnv -tf并在激活VirEnv后安装tensorflow

conda create --name tf python=3.9
conda activate tf
pip install --upgrade pip
pip install tensorflow编号或
conda install tensorflow
请按照所有软件要求在系统中启用Tensorflow GPU支持,并将它们添加到PATH的bin目录中。

  • 然后安装CUDA,cuDNN与conda并安装tensorflow。

x1米11米1x
pip install "tensorflow-gpu<2.11" #GPU设置不支持TF 2.11
现在,您可以验证是否已成功安装TensorFlow。

import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus, cpus)

**注意:**请确保您已根据此测试构建配置安装了与系统中已安装Python和TensorFlow版本兼容的正确CUDA和cuDNN。

相关问题