业精于勤荒于嬉
行成于思毁于随
昨天部署项目遇到错误
OSError: libcusparse.so.11: cannot open shared object file: No such file or directory
尝试了很多种方法,最终发现是原来装的/usr/local/CUDA-11.4中只有target文件夹,因此需要重新装。同时,有多个项目需要部署,它们用的是不同的CUDA,所以需要安装多个版本并切换。
https://developer.nvidia.com/cuda-toolkit-archive
/usr/local/
,后面会多次提到vi ~/.bashrc
末端加上配置信息export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
export PATH=${CUDA_HOME}/bin:${PATH}
/usr/local/cuda
是一个软连接,去usr/local/cuda
一看便知,后面的不同版本CUDA切换会与之有关source ~/.bashrc
使之生效nvcc -V
查看CUDA版本信息root@Tower:~# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0
cd /usr/local/cuda-11.1/samples/1_Utilities/deviceQuery
make
./deviceQuery
https://developer.nvidia.com/rdp/cudnn-archive
tar -zxvf cudnn-11.3-linux-x64-v8.2.1.32.tgz
/usr/local/cuda-11.1/
对应文件夹中,修改其权限sudo cp cuda/include/* /usr/local/cuda-11.1/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-11.1/lib64/
sudo chmod a+r /usr/local/cuda-11.1/include/cudnn.h
sudo chmod a+r /usr/local/cuda-11.1/lib64/libcudnn*
/usr/local/cuda-11.1/include
中的cudnn_version.h文件中查看,本文演示的版本为8.2.1、#define CUDNN_MAJOR 8
#define CUDNN_MINOR 2
#define CUDNN_PATCHLEVEL 1
去/usr/local
目录下可以看到软连接
lrwxrwxrwx 1 root root 20 7月 8 22:27 cuda -> /usr/local/cuda-11.1/
drwxr-xr-x 19 root root 4096 7月 8 21:59 cuda-10.0/
drwxr-xr-x 16 root root 4096 7月 8 17:05 cuda-11.1/
此时,系统使用的CUDA版本为11.1,如下所示:
root@Tower:/usr/local# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0
想要更改为CUDA-10.0,将软链接cuda重新链接到cuda-10.0即可
root@Tower:/usr/local# ln -snf /usr/local/cuda-10.0 /usr/local/cuda
重新运行nvcc -V
命令,即可发现CUDA版本已切换
root@Tower:/usr/local# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130