系统相关
首页 > 系统相关> > 纯净Ubuntu16安装CUDA(9.1)和cuDNN

纯净Ubuntu16安装CUDA(9.1)和cuDNN

作者:互联网

欢迎访问我的GitHub

https://github.com/zq2599/blog_demos

内容:所有原创文章分类汇总及配套源码,涉及Java、Docker、Kubernetes、DevOPS等;

本篇概览

  1. 准备工作
  2. 安装Nvidia驱动
  3. 安装CUDA
  4. 安装cuDNN

特别问题说明

准备工作

sudo apt-get remove --purge nvidia*
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
update-initramfs -u
lsmod|grep nouveau
sudo apt-get install linux-source

在这里插入图片描述

sudo apt-get install linux-headers-4.4.0-210-generic

下载和安装Nvidia驱动

在这里插入图片描述

在这里插入图片描述

sudo service lightdm stop
sudo chmod a+x NVIDIA-Linux-x86_64-460.84.run
sudo ./NVIDIA-Linux-x86_64-460.84.run -no-x-check -no-nouveau-check -no-opengl-files

在这里插入图片描述

sudo service lightdm start
will@lenovo:~/temp/202106/20$ nvidia-smi
Sun Jun 20 09:02:11 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.84       Driver Version: 460.84       CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 950M    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P0    N/A /  N/A |      0MiB /  4046MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

安装CUDA

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

https://developer.download.nvidia.cn/compute/cuda/9.1/secure/Prod/local_installers/cuda_9.1.85_387.26_linux.run?P0Ntu_6NLtuuEMm6fJRk1W5vl4KM7oaT1oFW870zKJ-zDw2ckKntFLOE6klRJfw2CmTa8z3Q390_6urlgc6LqjoqlIFW9gvfvDCusnINYplLaw1u8lRY8R4oVNtpNzaXU4BQcHjvdb6c6rjq20dktCcRd4640woXt1yHmD95v1Du7wdBBXq2eOY

https://developer.download.nvidia.cn/compute/cuda/9.1/secure/Prod/patches/1/cuda_9.1.85.1_linux.run?yeXf_7wIGlHAUw--E_YVLQZRgXv0x2i043woJVY-ydXU5Kyhc-eYQf5JmL-4mvYmlvPYCEc5RhT2sDWscX20CJbdOwpkt30kWb9vx8E4oIlajDQ3MVPvXdiKKsIOBUx-h0q0N0jSkNn80VMhW-nk8jwvRY_e6MuFzqWBaPk

https://developer.download.nvidia.cn/compute/cuda/9.1/secure/Prod/patches/2/cuda_9.1.85.2_linux.run?5jGZxNigaOJkaaPbMagjhSW7ebQvYGyYoqe2vBxZ1eV8qp2BzXJLxIPgAo11UgWhORirQkdJGq5b8eFh4aShBVUTmuPaasvRiMCKDZw5yjjIobGQrCEyU-LFO59AbrRER57Mxa0T1Sc97fC80IOZq8Ox2repjn7A3oYVgd8

https://developer.download.nvidia.cn/compute/cuda/9.1/secure/Prod/patches/3/cuda_9.1.85.3_linux.run?CxWimJTC-XROYihig-UZmH62odbJInf1fmxTZ_bsW1nQ0Zz5cL5r8qLmlMR_1j2rVhk3j8Z5lS6dpArt8frjGHH2MeVn5TefMoclam8udm-RSMMmqHXYE66hHN2D0drVEdtCwe8ZrEIYb2rpucaz9svCFE8Z319mge4Ju94
sudo sh cuda_9.1.85_387.26_linux.run

在这里插入图片描述

在这里插入图片描述

Installing the CUDA Toolkit in /usr/local/cuda-9.1 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so

Installing the CUDA Samples in /home/will ...
Copying samples to /home/will/NVIDIA_CUDA-9.1_Samples now...
Finished copying samples.

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-9.1
Samples:  Installed in /home/will, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-9.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-9.1/lib64, or, add /usr/local/cuda-9.1/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.1/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.1/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver

Logfile is /tmp/cuda_install_13425.log
export PATH=/usr/local/cuda-9.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64
sudo echo "/usr/local/cuda-9.1/lib64" >> /etc/ld.so.conf
ldconfig
will@lenovo:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
sudo sh cuda_9.1.85.1_linux.run
sudo sh cuda_9.1.85_387.26_linux.run
sudo sh cuda_9.1.85_387.26_linux.run

安装cuDNN

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

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
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 1
#define CUDNN_PATCHLEVEL 3
--
#define CUDNN_VERSION    (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"

你不孤单,欣宸原创一路相伴

  1. Java系列
  2. Spring系列
  3. Docker系列
  4. kubernetes系列
  5. 数据库+中间件系列
  6. DevOps系列

欢迎关注公众号:程序员欣宸

微信搜索「程序员欣宸」,我是欣宸,期待与您一同畅游Java世界...
https://github.com/zq2599/blog_demos

标签:run,sudo,cuDNN,CUDA,Ubuntu16,local,9.1,cuda
来源: https://www.cnblogs.com/bolingcavalry/p/15396057.html