查询默认CUDA/cuDNN版本 注意:通过nvidia-smi命令查看到的CUDA版本只是驱动支持的最高cuda版本参数,不代表实例中安装的是该版本CUDA。 终端中执行查看默认镜像自带的CUDA版本(安装目录为/usr/local/):
# 查询平台内置镜像中的cuda版本 ldconfig -p | grep cuda libnvrtc.so.11.0 (libc6,x86-64) => /usr/local/cuda-11.0/targets/x86_64-linux/lib/libnvrtc.so.11.0 libnvrtc.so (libc6,x86-64) => /usr/local/cuda-11.0/targets/x86_64-linux/lib/libnvrtc.so libnvrtc-builtins.so.11.0 (libc6,x86-64) => /usr/local/cuda-11.0/targets/x86_64-linux/lib/libnvrtc-builtins.so.11.0 # 查询平台内置镜像中的cudnn版本 ldconfig -p | grep cudnn libcudnn_ops_train.so.8 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8 libcudnn_ops_train.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so libcudnn_ops_infer.so.8 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8 libcudnn_ops_infer.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so
上边的输出日志.so后的数字即为版本号。如果你通过conda安装了cuda那么可以通过以下命令查看:conda list | grep cudatoolkit cudatoolkit 10.1.243 h6bb024c_0 defaults conda list | grep cudnn cudnn 7.6.5 cuda10.1_0 defaults安装其他版本的CUDA/cuDNN方法一:使用conda进行安装 优点:简单 缺点:一般不会带头文件,如果需要做编译,则需要照方法二安装 安装方法:conda install cudatoolkit==xx.xx conda install cudnn==xx.xx 如果你不知道版本号是什么那么可以搜索:conda search cudatoolkit Loading channels: done # Name Version Build Channel cudatoolkit 9.0 h13b8566_0 anaconda/pkgs/main cudatoolkit 9.2 0 anaconda/pkgs/main cudatoolkit 10.0.130 0 anaconda/pkgs/main cudatoolkit 10.1.168 0 anaconda/pkgs/main cudatoolkit 10.1.243 h6bb024c_0 anaconda/pkgs/main cudatoolkit 10.2.89 hfd86e86_0 anaconda/pkgs/main cudatoolkit 10.2.89 hfd86e86_1 anaconda/pkgs/main cudatoolkit 11.0.221 h6bb024c_0 anaconda/pkgs/main cudatoolkit 11.3.1 h2bc3f7f_2 anaconda/pkgs/main方法二:下载安装包安装 CUDA下载地址:https://developer.nvidia.com/cuda-toolkit-archive 安装方法:# 下载.run格式的安装包后: chmod +x xxx.run # 增加执行权限 ./xxx.run # 运行安装包 CUDNN下载地址:https://developer.nvidia.com/cudnn 安装方法: 先解压, 后将动态链接库和头文件放入相应目录mv cuda/include/* /usr/local/cuda/include/ chmod +x cuda/lib64/* && mv cuda/lib64/* /usr/local/cuda/lib64/ 安装完成以后,增加环境变量:echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} \n" >> ~/.bashrc source ~/.bashrc && ldconfig
conda list | grep cudatoolkit cudatoolkit 10.1.243 h6bb024c_0 defaults conda list | grep cudnn cudnn 7.6.5 cuda10.1_0 defaults
conda search cudatoolkit Loading channels: done # Name Version Build Channel cudatoolkit 9.0 h13b8566_0 anaconda/pkgs/main cudatoolkit 9.2 0 anaconda/pkgs/main cudatoolkit 10.0.130 0 anaconda/pkgs/main cudatoolkit 10.1.168 0 anaconda/pkgs/main cudatoolkit 10.1.243 h6bb024c_0 anaconda/pkgs/main cudatoolkit 10.2.89 hfd86e86_0 anaconda/pkgs/main cudatoolkit 10.2.89 hfd86e86_1 anaconda/pkgs/main cudatoolkit 11.0.221 h6bb024c_0 anaconda/pkgs/main cudatoolkit 11.3.1 h2bc3f7f_2 anaconda/pkgs/main
mv cuda/include/* /usr/local/cuda/include/ chmod +x cuda/lib64/* && mv cuda/lib64/* /usr/local/cuda/lib64/
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} \n" >> ~/.bashrc source ~/.bashrc && ldconfig