[work] 安装多版本 cuda 多版本之间切换

﹏ヽ暗。殇╰゛Y 2022-04-11 03:48 422阅读 0赞
  1. cuda 的下载与安装方法选择

到 CUDA Toolkit Download 下载所需版本,以 cuda_9.0.176_384.81_linux.run为例:
这里写图片描述

建议选择使用 .run 文件安装,因为使用 .deb可能会将已经安装的较新的显卡驱动替换。

  1. cuda 安装

进入到放置 cuda_9.0.176_384.81_linux.run 的目录:

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

在安装过程中截取其中比较重要的几个选择:

  1. Do you accept the previously read EULA?
  2. accept/decline/quit: accept
  3. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
  4. (y)es/(n)o/(q)uit: n # 如果在这之前已经安装好更高版本的显卡驱动就不需要再重复安装,如果需要重复安装就选择 yes,此外还需要关闭图形界面。
  5. Install the CUDA 9.0 Toolkit?
  6. (y)es/(n)o/(q)uit: y
  7. Enter Toolkit Location
  8. [ default is /usr/local/cuda-9.0 ]: # 一般选择默认即可,也可以选择安装在其他目录,在需要用的时候指向该目录或者使用软连接 link 到 /usr/local/cuda。
  9. /usr/local/cuda-9.0 is not writable.
  10. Do you wish to run the installation with 'sudo'?
  11. (y)es/(n)o: y
  12. Please enter your password:
  13. Do you want to install a symbolic link at /usr/local/cuda? # 是否将安装目录通过软连接的方式 link 到 /usr/local/cuda,yes or no 都可以,取决于你是否使用 /usr/local/cuda 为默认的 cuda 目录。
  14. (y)es/(n)o/(q)uit: n
  15. Install the CUDA 9.0 Samples?
  16. (y)es/(n)o/(q)uit: n

前面选择的一些汇总:

  1. Driver: Not Selected
  2. Toolkit: Installed in /usr/local/cuda-9.0
  3. Samples: Not Selected
  4. Please make sure that
  5. - PATH includes /usr/local/cuda-9.0/bin
  6. - 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
  7. To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.0/bin
  8. Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up CUDA.
  9. ***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.
  10. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
  11. sudo <CudaInstaller>.run -silent -driver

安装完成后可以在 /usr/local 目录下看到:

  1. cuda-8.0 # 笔者之前安装的cuda-8.0
  2. cuda-9.0 # 刚刚安装的cuda-9.0
  3. cuda # cuda-8.0 的软连接
  1. 多个 cuda 版本之间进行切换

将~/.bashrc 或 ~/.zshrc 下与cuda相关的路径都改为 /usr/local/cuda/ 而不使用 /usr/local/cuda-8.0/ 或/usr/local/cuda-9.0/。

  1. #在切换cuda版本时
  2. rm -rf /usr/local/cuda#删除之前创建的软链接
  3. sudo ln -s /usr/local/cuda-8.0/ /usr/local/cuda/
  4. nvcc --version #查看当前 cuda 版本
  5. nvcc: NVIDIA (R) Cuda compiler driver
  6. Copyright (c) 2005-2016 NVIDIA Corporation
  7. Built on Mon_Jan_23_12:24:11_CST_2017
  8. Cuda compilation tools, release 8.0, V8.0.62
  9. #cuda8.0 切换到 cuda9.0
  10. rm -rf /usr/local/cuda
  11. sudo ln -s /usr/local/cuda-9.0/ /usr/local/cuda/
  12. nvcc --version

发表评论

表情:
评论列表 (有 0 条评论,422人围观)

还没有评论,来说两句吧...

相关阅读

    相关 版本cuda共存

    1. 首先在机器中安装一个版本的cuda,参考链接。 2. 然后再安装另一个版本的cuda时,不要配置环境变量(这样可以保证默认使用第一个版本的cuda),然后安装相应版本