赞
踩
自己学习使用,用以记录,以防遗忘。也希望对大家有所帮助。
(默认已安装anaconda、显卡驱动)
默认已下载cuda11.1,如下图所示选择相应版本(ubuntu向下兼容,22.04可选20.04版本的cuda)
注意选择runfile方法
在服务器终端输入:
- wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
-
- sudo sh cuda_11.1.0_455.23.05_linux.run
进行安装即可。
接着下载cuda11.8!版本选择按照上述图片进行选择,如果你选择11.8.0,可直接按照我下面的代码进行安装。(输入后会卡一下,耐心等待)
- wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
- sudo sh cuda_11.8.0_520.61.05_linux.run
安装过程中
第一步:选择accept
第二步:第一项不选(回车取消选择),已安装显卡驱动
选择后小键盘移动到:install 回车
第三步:应该是a symbol ...什么什么的 选择 no(不要选择yes!!)
等待....
出现和下面的类似代码表示安装成功!
- ===========
- = Summary =
- ===========
-
- Driver: Not Selected
- Toolkit: Installed in /usr/local/cuda-11.8/
-
- Please make sure that
- - PATH includes /usr/local/cuda-11.8/bin
- - LD_LIBRARY_PATH includes /usr/local/cuda-11.8/lib64, or, add /usr/local/cuda-11.8/lib64 to /etc/ld.so.conf and run ldconfig as root
-
- To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.8/bin
- ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 520.00 is required for CUDA 11.8 functionality to work.
- To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
- sudo <CudaInstaller>.run --silent --driver
-
- Logfile is /var/log/cuda-installer.log
编辑.bashrc
文件:
nano ~/.bashrc
在文件末尾添加以下内容(已有可跳过,版本号根据自身情况修改):
- export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
保存并退出后,更新环境变量:
source ~/.bashrc
编辑.bashrc
文件:
nano ~/.bashrc
在文件末尾添加以下内容(已有可跳过,版本号根据自身情况修改):
- export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
保存并退出后,更新环境变量:
source ~/.bashrc
创建脚本文件:
sudo nano /usr/local/bin/switch_cuda_11.1.sh
添加以下内容:
- #!/bin/bash
- export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- echo "Switched to CUDA 11.1"
保存并退出,赋予执行权限:
sudo chmod +x /usr/local/bin/switch_cuda_11.1.sh
创建脚本文件:
sudo nano /usr/local/bin/switch_cuda_11.8.sh
添加以下内容:
- #!/bin/bash
- export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- echo "Switched to CUDA 11.8"
保存并退出,赋予执行权限:
sudo chmod +x /usr/local/bin/switch_cuda_11.8.sh
切换到cuda11.1
source /usr/local/bin/switch_cuda_11.1.sh
切换到cuda11.8
source /usr/local/bin/switch_cuda_11.8.sh
每次切换后可使用
nvcc -V
验证。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。