在已经安装有cuda的情况下,安装另一个版本的cuda
下载cuda(run file)
注意了
- CUDA Toolkit Archive 下载对应cuda版本run文件,上传到服务器
- archlinux中安装cuda参考 ubunt版本
一般安装过程
chmod +x cuda.run
sh cuda.run*
正式开始安装cuda
以下为部分安装提示
Do you accept the previously read EULA?
accept/decline/quit: accept
#这一条提示不用管它
You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: n # 如果在这之前已经安装好更高版本的显卡驱动就不需要再重复安装,如果需要重复安装就选择 yes,此外还需要关闭图形界面。
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]:/home/usrname/usr/local/cuda-9.0
/usr/local/cuda-9.0 is not writable.
Do you wish to run the installation with ‘sudo’?
(y)es/(n)o: y
Please enter your password:
Do you want to install a symbolic link at /usr/local/cuda? # 是否将安装目录通过软连接的方式 link 到 /usr/local/cuda,yes or no 都可以,取决于你是否使用 /usr/local/cuda 为默认的 cuda 目录。
(y)es/(n)o/(q)uit: n
Install the CUDA 9.0 Samples? #安装与否没有影响
(y)es/(n)o/(q)uit: n
一般情况下到此安装成功了。但是也可能出现提示错误
我遇到了两种提示
1.Error: unsupported compiler: 10.2.0. Use --override to override this check.
2.Use --toolkitpath to specify the toolkit location.
第一种错误的解决方法,如提示所说:在sh cuda*.run 加上–override参数:
sh cuda.run --override*
第二种错误的解决方法:
export $PERL5LIB
sh ./cuda_8.0.44_linux.run --no-opengl-libs --override
接下来安装成功,可以在/home/usrname/usr/local目录下看到cuda-9.0,这就是安装文件。
但是现在还不能使用nvcc -V 提示的还是服务器的cuda。
添加环境变量到.bashrc
回到用户根目录下,ls -a可以看到.bashrc文件,
vim .bashrc
添加以下
export PATH=/home/usrname/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/home/usrname/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
退出保存,
source .bashrc
现在可以使用nvcc -V查看到刚刚安装的cuda版本不同于服务器上的cuda版本。