Linux下深度学习环境CUDA和cuDNN的配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LoverJuan/article/details/88056953

1、检查当前设备可安装驱动

ubuntu-drivers devices

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000139Bsv0000152Dsd00001129bc03sc02i00
vendor   : NVIDIA Corporation
model    : GM107M [GeForce GTX 960M]
driver   : nvidia-driver-396 - third-party free
driver   : nvidia-driver-415 - third-party free recommended
driver   : nvidia-driver-390 - third-party free
driver   : nvidia-driver-410 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

2、安装最新驱动

sudo apt install nvidia-415

3、下载CUDA

    1、到 https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html  查询可配对版本

    2、官网下载:https://developer.nvidia.com/cuda-toolkit-archive run文件

    3、执行安装文件

sudo sh cuda_10.0.130_410.48_linux.run

长按空格一直到下方0%变为

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

输入accept如上所示,回车后出现的第一个

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

扫描二维码关注公众号,回复: 5377128 查看本文章


其他的都选yes

出现输入安装路径时,直接回车表示使用默认路径。

4、查看显卡驱动版本和CUDA版本

nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 415.27       Driver Version: 415.27       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+


5、环境配置

sudo gedit ~/.bashrc

在最下方添加

export PATH=/usr/local/cuda-你的CUDA版本号/bin${PATH:+:${PATH}} 
export LD_LIBRARY_PATH=/usr/local/cuda-你的CUDA版本号/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

6、检验是否成功安装CUDA

测试一:

输入:
nvcc -V
显示:
nvcc: NVIDIA (R) Cuda compiler driver等等信息

测试二:

如果是默认目录,会在~目录下面有一个NVIDIA_CUDA-10.0_Samples文件夹

编译一个vectorAdd的文件出来,然后运行测试
~/NVIDIA_CUDA-10.0_Samples/0_Simple/vectorAdd$ make
多处一个vectorAdd文件
:~/NVIDIA_CUDA-10.0_Samples/0_Simple/vectorAdd$ ./vectorAdd 

[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done


表示正常!

7、安装cuDNN

官网:https://developer.nvidia.com/rdp/cudnn-download

需要注册登陆后再点击上面链接下载,一定要下载与CUDA对应的版本

下载cuDNN Library for Linux

解压:

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

拷贝文件到cuda安装目录中:

sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn*    /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h   /usr/local/cuda/lib64/libcudnn*

猜你喜欢

转载自blog.csdn.net/LoverJuan/article/details/88056953
今日推荐