ubuntu22.04安装cuda11.5+cudnn8.8.0
因为pytorch1.11.0与cuda版本的关系 需要用到cuda11.5
(图片来源网络,侵删)
否则报错
"addmm_sparse_cuda" not implemented for Half
cuda11.5.0及以前的版本不会出现这个问题
因此重新安装,步骤如下:
安装CUDA-11.5.0
wget https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda_11.5.0_495.29.05_linux.run sudo sh cuda_11.5.0_495.29.05_linux.run
修改路径~/.bashrc
export PATH=$PATH:/usr/local/cuda/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 export CUDA_HOME=/usr/local/cuda
安装cuDNN-8.8.0
下载路径:
cuDNN Archive | NVIDIA Developer
sudo dpkg -i cudnn-local-repo-ubuntu2204-8.8.0.121_1.0-1_amd64.deb sudo apt-get update sudo apt-get install libcudnn8=8.8.0.121-1+cuda11.8 sudo apt-get install libcudnn8-dev=8.8.0.121-1+cuda11.8 sudo apt-get install libcudnn8-samples=8.8.0.121-1+cuda11.8
安装完成后可查看
cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2 #define CUDNN_MAJOR 8 #define CUDNN_MINOR 8 #define CUDNN_PATCHLEVEL 0 -- #define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL) /* cannot use constexpr here since this is a C-only file */
表示输出正常!
正确的计算代码应该是
import torch a = torch.randn(3,2).half().cuda() i = torch.LongTensor([[0, 1, 1], [2, 0, 2]]) v = torch.FloatTensor([3, 4, 5]) b = torch.sparse.FloatTensor(i, v, torch.Size([2,3])).half().cuda() b = b.to_sparse_csr() c = torch.spmm(b, a)
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。