Blogger Information
Blog 291
fans 0
comment 0
visits 352488
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Ubuntu下安装CUDA
Original
1766 people have browsed it

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

注意:
Ubuntu18.04默认GCC-7,由于CUDA 9.x不支持GCC-7(下载页面没有对ubuntu18的支持),所以需要安装低版本的5或者<= 6.3.0,并设置为默认版本。否则应安装10.0以上版本CUDA

1.查看是否安装了cuda

  1. # 法1
  2. cat /usr/local/cuda/version.txt
  3. # 法2
  4. nvcc --version

2.若没有安装,则查看是否有N卡驱动,若无N卡驱动,则到软件与更新 -> 附加驱动中安装驱动

3.查看N卡驱动支持的cuda版本

  1. nvidia-smi

如下图支持最高CUDA版本是11.4

file

4.到cuda-toolkit-archive,选择需要的CUDA下载

5.如下图,选择runfile(local),并使用生成的指令进行下载和安装

file

若第1步提示Existing package manager installation of the driver found. It is strongly recommended that you remove this before continuing.,选择continue,在下一步中去除driver项,之后选择install:

file

安装完成后,显示如下:

file

6.在~/.bashrc文件中添加如下环境变量:

  1. export PATH=/usr/local/cuda-11.3/bin${PATH:+:${PATH}}
  2. export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

7.验证是否安装成功

  1. nvcc -V

file

8.安装cuDNN,到cudnn-archive下载和CUDA对应的版本

  1. 1.Navigate to your <cudnnpath> directory containing the cuDNN tar file.
  2. 2.Unzip the cuDNN package.
  3. $ tar -xvf cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz
  4. 3. Copy the following files into the CUDA toolkit directory.
  5. $ sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
  6. $ sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
  7. $ sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

按照↑教程,可下载cuDNN Library for Linux (x86_64)用复制的方式安装,使用如下命令查看安装版本

  1. cat /usr/local/cuda-11.3/include/cudnn.h | grep CUDNN_MAJOR -A 2

9.也可下载Runtime Library和Developer Library的deb包,使用sudo dpkg -i xxx.deb命令进行安装,使用如下命令查看安装版本

  1. cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

10.多版本CUDA安装重复上述步骤即可,最后通过更改第6步中环境变量切换CUDA版本

本文转自:https://blog.csdn.net/CC977/article/details/122789394

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post