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

个人机器是CUDA16.04的,以前装过CUDA10.0,由于一些缘由,如今须要安转CUDA9.0。linux

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

下载run版本的(若是以前没装过CUDA,能够下载deb版本的)ide

2.按照上面的教程ui

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.相关参数的设置this

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.安转结束后相关环境变量的设置spa

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,让其生效。code

完成上面这些步骤后,就能够进行多个版本的切换了,直接修改/usr/local/cuda便可,使其指向不一样版本的CUDA。orm

相关文章
相关标签/搜索