欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

ubuntu16.04如何安装多个版本的CUDA

程序员文章站 2022-10-18 11:10:33
我的机器是CUDA16.04的,之前装过CUDA10.0,因为一些原因,现在需要安转CUDA9.0。 1.首先https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target ......

我的机器是cuda16.04的,之前装过cuda10.0,因为一些原因,现在需要安转cuda9.0。

1.首先https://developer.nvidia.com/cuda-90-download-archive?target_os=linux&target_arch=x86_64&target_distro=ubuntu&target_version=1604&target_type=runfilelocal

下载run版本的(如果之前没装过cuda,可以下载deb版本的)

2.按照上面的教程

sudo chmod +x cuda_9.0.176_384.81_linux.run # 为 cuda_9.0.176_384.81_linux.run 添加可执行权限 
./cuda_9.0.176_384.81_linux.run # 安装 cuda_9.0.176_384.81_linux.run

3.相关参数的设置

install nvidia accelerated graphics driver for linux-x86_64 384.81?

(y)es/(n)o/(q)uit: n #我已经装过cuda10了,所以不需要安转9.0的显卡驱动

install the cuda 9.0 toolkit? 
(y)es/(n)o/(q)uit: y


/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: y  #我目前需要使用9.0

 

enter toolkit location
[ default is /usr/local/cuda-9.0 ]:#直接回车

 

4.安转结束后相关环境变量的设置

finished copying samples.

===========
= summary =
===========

driver:   not selected
toolkit:  installed in /usr/local/cuda-9.0
samples:  installed in /usr/local/cuda-9.0/samples

please make sure that
 -   path includes /usr/local/cuda-9.0/bin
 -   ld_library_path includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.0/lib64 to /etc/ld.so.conf and run ldconfig as root

to uninstall the cuda toolkit, run the uninstall script in /usr/local/cuda-9.0/bin

please see cuda_installation_guide_linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up cuda.

***warning: incomplete installation! this installation did not install the cuda driver. a driver of version at least 384.00 is required for cuda 9.0 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 /tmp/cuda_install_11003.log

如上,需要设置path和ld_library_path两个变量,在./bashrc文件中修改即可,记得要source一些./bashrc,让其生效。

完成上面这些步骤后,就可以进行多个版本的切换了,直接修改/usr/local/cuda即可,使其指向不同版本的cuda。