ubuntu卸载cuda8.0,、安装cuda9.0以及cudnn安装教程

卸载cuda8.0

sudo service lightdm stop
ctrl + alt + F1 , 输入账号和密码
cd /usr/local/cuda-8.0/bin
sudo ./uninstall_cuda_8.0.pl
cd ../..
sudo rm -rf cuda8.0

安装cuda9.0

下载cuda9.0

cd Dowload/
sudo sh cuda_9.0.176_384.81_linux.run --no-opengl-libs 

推荐按照下面的选择进行安装


Do you accept the previously read EULA?
accept/decline/quit:accept   

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 387.26?
(y)es/(n)o/(q)uit: n

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

Enter Toolkit Location
 [ default is /usr/local/cuda-9.0 ]: 
直接按enter

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

Install the CUDA 9.0 Samples?

配置环境变量

sudo gedit /etc/profile
export PATH=/usr/local/cuda-9.0/bin/:$PATH  
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/

测试

#编译并测试设备 deviceQuery:  
 cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery  
 sudo make  
 ./deviceQuery  

 #编译并测试带宽 bandwidthTest:  
 cd ../bandwidthTest  
 sudo make  
 ./bandwidthTest 

查看cuda版本

cat /usr/local/cuda/version.txt
或者重启后
nvcc -V

安装cudnn

cuDNN(CUDA Deep Neural Network

官网

安装
相比标准的cuda,它在一些常用的神经网络操作上进行了性能的优化,比如卷积,pooling,归一化,以及激活层等等。

1.下载cuDNN压缩包

2.解压

tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz

3.拷贝

解压后会看到一个cuda文件夹,里面包含了include以及lib64两个子目录。将这两个文件夹里的文件复制到cuda对应的安装目录。这里以cuda的安装目录为/usr/local/cuda/为例:

cd cuda
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/* /usr/local/cuda/lib64/

注意:要加sudo,为了获取权限。

4.链接

cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.5
sudo ln -s libcudnn.so.6.0.21 libcudnn.so.6
sudo ln -s libcudnn.so.6 libcudnn.so

5.验证

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

你可能感兴趣的:(linux)