查看torch需要的cuda版本:
conda list | grep cu |
下载地址
cuda:
https://developer.nvidia.com/cuda-toolkit-archive
cudnn:
https://developer.nvidia.com/rdp/cudnn-archive
安装
cudawget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
sudo sh cuda_11.7.1_515.65.01_linux.run
cudnn
注意:由于cudnn需要登录,所以最好手动下载,wget下载的文件有问题wget https://developer.nvidia.com/compute/cudnn/secure/8.5.0/local_installers/11.7/cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.xz(替换为手动下载)
tar -xvf cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.xz
cd cudnn-linux-x86_64-8.5.0.96_cuda11-archive
sudo cp include/cudnn* /usr/local/cuda/include/
sudo cp lib/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
配置环境
编译bashrc或者zshrc,以zshrc为例
打开zshrc:vi ~/.zshrc
export PATH=/usr/local/cuda-11.7/bin:$PATH |
更新环境变量source ~/.zshrc