ubuntu18.04安装cuda-10.0和cudnn-7.4.2

安装cuda-10.0

1. Ubuntu18.04默认gcc/g++ 7.3版本,但是cuda 9并不支持gcc/g++7,所以先降级至6或6以下

2.安装cuda依赖

sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev

3.在官网下载cuda“run”file

下载cuda10.0

4.cd到cuda10.0文件夹,运行 runfile

sudo sh cuda_10.0.130_410.48_linux.run

如果已经正确安装驱动,注意第二个问题选择"n"

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 396.26?
(y)es/(n)o/(q)uit: n

Install the CUDA 9.2 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-9.2 ]:

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 9.2 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /home/kinghorn ]: /usr/local/cuda-9.2

5.安装 cuBLAS patch

sudo sh cuda_10.0.130.1_linux.run

6.配置环境

6.1 如果需要多版本cuda共存

这个方法可以让你切换不同的cuda环境,当你需要哪cuda环境时候激活即可。在某个路径中写个脚本,名为cuda9.2-env

export PATH=$PATH:/usr/local/cuda-10.0/bin
export CUDADIR=/usr/local/cuda-10.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64

激活环境

source cuda10.0-env

6.2只需要一个cuda环境,无需切换,直接在~/.bashrc

export PATH=/usr/local/cuda-10.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/64:$LD_LIBRARY_PATH

7.检查版本

nvcc -V

或者

cat /usr/local/cuda/version.txt

如果出现的版本信息没错,即安装成功。

cudnn7.4安装

1.解压文件

tar -zxvf cudnn-10.0-linux-x64-v7.4.2.24.tgz

2.在终端输入

sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64
 #修改权限
sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*

3.检查cudnn版本

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

你可能感兴趣的:(Linux)