Installation and uninstallation of CUDA under Ubuntu 16.04

1. Download cuda.xxx.run file#

Download the cuda_9.1.85_387.26_linux.run file from https://developer.nvidia.com/cuda-downloads

2. Just run this command in the terminal:

$ sudo sh cuda_9.1.85_387.26_linux.run --no-opengl-libs

After that is some prompt information, enter accept after ctrl+c directly ends.
The next important point is when prompted whether to install the graphics card driver, be sure to select no (the driver for the corresponding graphics card version has been installed before)
Choose Yes for other prompts, and install the path by default. It is prompted to enter y for y, if not, press enter. Installed.
Then declare the environment variable and write it to the end of the ~/.bashrc file (under the user directory), the input is as follows

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

Save and exit, and enter the following command to make the environment variable take effect immediately:

$source ~/.bashrc

3. Set environment variables and dynamic link library, enter on the command line:

$sudo vim /etc/profile

Add at the end of the opened file:

export PATH=/usr/local/cuda/bin:$PATH

4. Create link file#

$ sudo vim /etc/ld.so.conf.d/cuda.conf

Add the following statement to the opened file:

/usr/local/cuda/lib64

Save and exit, then execute

$ sudo ldconfig 

Make the link effective immediately.

5. Test the Samples of cuda

Switch to the default installation path of CUDA 9.1 Samples (that is, under the /home/user/NVIDIA_CUDA-9.1_Samples directory), enter in the terminal

$ cd NVIDIA_CUDA-9.1_Samples
$ sudo make all –j8
$ cd bin/x86_64/linux/release
$ ./deviceQuery

Report an error

$ ./deviceQuery
. /deviceQuery Starting...

 CUDA Device Query(Runtime API)version(CUDART static linking)

cudaGetDeviceCount returned 30-> unknown error
Result = FAIL

Check if the graphics card is installed

$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

Found that the graphics card driver was not installed successfully
And nouveau disable failed

$ lsmod | grep nouveau
nouveau              16015361
mxm_wmi                163841 nouveau
ttm                    983041 nouveau
i2c_algo_bit           163842 nouveau,i915
drm_kms_helper        1515522 nouveau,i915
drm                   35225614 nouveau,i915,ttm,drm_kms_helper
wmi                    163842 mxm_wmi,nouveau
video                  409603 thinkpad_acpi,nouveau,i915

This is to disable nouveau again and install the graphics driver

If the CUDA installation is successful, there are:

$ ./deviceQuery
. /deviceQuery Starting...

 CUDA Device Query(Runtime API)version(CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0:"GeForce GT 635M"
 CUDA Driver Version / Runtime Version          9.0/8.0
 CUDA Capability Major/Minor version number:2.1
 Total amount of global memory:1985MBytes(2081619968 bytes)(2) Multiprocessors,(48) CUDA Cores/MP:96 CUDA Cores
 GPU Max Clock rate:950MHz(0.95 GHz)
 Memory Clock rate:900 Mhz
 Memory Bus Width:128-bit
 L2 Cache Size:131072 bytes
 Maximum Texture Dimension Size(x,y,z)         1D=(65536), 2D=(65536,65535), 3D=(2048,2048,2048)
 Maximum Layered 1D Texture Size,(num) layers  1D=(16384),2048 layers
 Maximum Layered 2D Texture Size,(num) layers  2D=(16384,16384),2048 layers
 Total amount of constant memory:65536 bytes
 Total amount of shared memory per block:49152 bytes
 Total number of registers available per block:32768
 Warp size:32
 Maximum number of threads per multiprocessor:1536
 Maximum number of threads per block:1024
 Max dimension size of a thread block(x,y,z):(1024,1024,64)
 Max dimension size of a grid size(x,y,z):(65535,65535,65535)
 Maximum memory pitch:2147483647 bytes
 Texture alignment:512 bytes
 Concurrent copy and kernel execution:          Yes with1 copy engine(s)
 Run time limit on kernels:                     No
 Integrated GPU sharing Host Memory:            No
 Support host page-locked memory mapping:       Yes
 Alignment requirement for Surfaces:            Yes
 Device has ECC support:                        Disabled
 Device supports Unified Addressing(UVA):      Yes
 Device PCI Domain ID / Bus ID / location ID:0/1/0
 Compute Mode:<Default(multiple host threads can use ::cudaSetDevice()with device simultaneously)>

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version =9.0, CUDA Runtime Version =8.0, NumDevs =1, Device0 = GeForce GT 635M
Result = PASS

6. Uninstall CUDA

In the /usr/local/cuda/bin directory, there is the uninstall tool uninstall_cuda_9.1.pl that comes with cuda

$ cd /usr/local/cuda/bin
$ sudo ./uninstall_cuda_9.1.pl

7. other problems#

View NVIDIA GPU version information

$ lspci | grep -i nvidia

01:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 635M](rev a1)

Verify that your Linux version supports CUDA

$ uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

Check the running system kernel version:

 $  uname –r
4.10.0- 28- generic

Install the kernel header and package development corresponding to the kernel version

sudo apt-get install linux-headers-$(uname -r)

Check whether nouveau driver is disabled

lsmod | grep nouveau

If there is output, it means nouveau is loading. We need to manually ban nouveau, Ubuntu’s nouveau ban method mentioned earlier

See link:
http://blog.csdn.net/qlulibin/article/details/78714596

Recommended Posts

Installation and uninstallation of CUDA under Ubuntu 16.04
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Installation, configuration and uninstallation of GitLab in Ubuntu19.1
Installation and use of GDAL in Python under Ubuntu
Installation and usage instructions of rz/sz command under ubuntu
Installation of deb package under Ubuntu
Redis installation under ubuntu and windows
Installation of Docker CE under Ubuntu
ubuntu Docker installation and deployment of Rancher
Installation and configuration of redis under centos7
Installation and deployment of Nginx in Ubuntu
Installation and use of Win10 subsystem Ubuntu
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
Ubuntu introduction and installation
[python] python2 and python3 under ubuntu
LNMP installation under Ubuntu
Installation and configuration of rsync server under CentOS 6.5
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation and use of SSH in Ubuntu environment
Installation and cracking of confluence6.3 operation records under Centos
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Installation and cracking of Jira7 operation records under Centos
Ubuntu16.04 installation and simple configuration
Installation and simple practice of MySQL in ubuntu environment (1)
Use of mediawiki under ubuntu
Ubuntu PostgreSQL installation and configuration
Happy installation of Jenkins in ubuntu
Installation under centos6.9 of jenkins learning
CentOS7 installation and maintenance of Gitlab
Install and deploy Gerrit under Ubuntu
Install nodejs and npm under Ubuntu 16.04
Java-JDK installation and configuration under CentOS
Ubuntu 16.04 installation graphic tutorial under VMware 12
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
Ubuntu18.04 installation Anaconda3 and VSCode guide
Erlang 20.2 installation and deployment under CentOS 7
Ubuntu configuration source and installation software
Compile and install QEMU under Ubuntu
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Ubuntu basic settings: introduction to the installation and use of openssh-server
Install the latest version of Thunderbird and exchange plugins under ubuntu
Installation of python common libraries under windows
Ubuntu installation and deployment Redash operation notes (2020.08)
51 MCU program development and download under Ubuntu
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Ubuntu18.04 system installation and prerequisite software installation guide
Centos7 installation and deployment of gitlab server
Ubuntu18.04 Server version installation and use (graphic)
The implementation of the Ubuntu18.04 installation Pycharm tutorial
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Install and uninstall CUDA and CUDNN on Ubuntu
Ubuntu 14.04 16.04 Linux nvidia driver download and installation
KVM installation and preliminary use under CentOS 7.2
GPU programming (1): CUDA8.0 environment construction under Ubuntu
Centos7 installation and deployment of Airflow detailed
Configure node js and npm under Ubuntu 14.04