在Ubuntu 20.4 LTS上使用GPU(CUDA11.0)运行代码时出现TensorFlow问题

2024-09-28 05:27:56 发布

您现在位置:Python中文网/ 问答频道 /正文

无法加载动态库'libcusparse.so.11';dlerror:libcusparse.so.11:无法打开共享对象文件:没有此类文件或目录

有人能帮我解决上面的问题吗

当我尝试执行以下代码时:

import tensorflow as tf
if __name__ == '__main__':
    print(tf.test.is_built_with_cuda())
    print(tf.config.list_physical_devices('GPU'))

我得到以下错误日志:

2021-03-07 23:47:41.236741: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
True
2021-03-07 23:47:41.953930: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-03-07 23:47:41.954322: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
[]
2021-03-07 23:47:41.981245: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-07 23:47:41.981758: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:06:00.0 name: GeForce GTX 970 computeCapability: 5.2
coreClock: 1.329GHz coreCount: 13 deviceMemorySize: 3.94GiB deviceMemoryBandwidth: 208.91GiB/s
2021-03-07 23:47:41.981769: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-03-07 23:47:41.983137: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-03-07 23:47:41.983159: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-03-07 23:47:41.984153: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-03-07 23:47:41.984274: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-03-07 23:47:41.985206: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-03-07 23:47:41.985276: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory
2021-03-07 23:47:41.985339: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-03-07 23:47:41.985344: 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...

Process finished with exit code 0

我手动检查了文件夹/usr/local/cuda-11.0/lib64,在日志libcusparse.so.11中也找不到提到的文件


我遵循了TensorFlow的官方安装步骤link

环境:

  • 操作系统:Ubuntu 20.04.2 LTS
  • GPU Geforce GTX 970
  • 驱动程序版本450.102.04
  • Cuda工具包V11.0
  • Cudnn V8.0.4.30(不完全确定如何检查)
  • Anaconda venv中的Python V3.7

Tags: defaultstreamgputensorflowlibrarydynamicloadercc
1条回答
网友
1楼 · 发布于 2024-09-28 05:27:56

只需重新安装Ubuntu并使用Lambda-Stack中的“一行程序”就可以解决这个问题

LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && sudo apt-get install -y lambda-stack-cuda
sudo reboot

相关问题 更多 >

    热门问题