Installation in Ubuntu18.04 environment:
The main reference is below this blog:
80483036
80144503
1. Install the GPU Nvidia driver (for ubuntu18.04) Step 1: First, test your NVIDIA graphics card and the recommended driver model. Execute command:
$ ubuntu-drivers Devices
The output is:
= =/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==modalias:pci: V000010ded00001180sv00001458sd0000353cbc03sc00i00vendor : NVIDIA corporationmodel : GK104 [GeForce GTX 680] Driver : Nvidia-304-distro non-freedriver : Nvidia-340-distro non-freedriver : Nvidia-384-distro non-fre E recommendeddriver : Xserver-xorg-video-nouveau-distro free builtin== cpu-microcode.py ==driver : Intel-microcode-distro Free
As you can see, one of the devices here is the GTX 680, the corresponding driver is nvidia-304,340,384, and the recommended is to install the 384 version of the driver.
STEP.2, installing the drive
You can choose to install all the recommended drivers, such as the following command
$ sudo ubuntu-drivers autoinstall
You can also choose to install only one of the drivers, the command is as follows
$ sudo apt install nvidia-340
OK driver installation Complete, reboot
4. Installation Cuda (for 18.04) the installation Cuda needs attention here;
We need to choose according to CUDNN, first of all, Cuda can only support 17.04,16.04 ubuntu download installation, but, in fact, a bit like word (high version Word can open the lower version of Word file. ) 18.04 version of the system, capable of installing the 16.04 version corresponding to Cuda.
Currently, Cuda has the highest version of 9.2 and only supports the 16.04,17.04 system, and we need to install CUDNN after we install CUDA.
So what are the options for the CUDNN version, as follows
First, according to the CUDNN version, at present, the more complete, is CUDNN v7.0.5, which applies to Cuda 9.1 version, so, we choose to install Cuda, the choice Cuda 9.1.
Press to select
Corresponding to have four files, need to download all, the first is the main file, the following 3 is equivalent to a patch.
To start the installation:
Step. 1 GCC downgrade
Since Cuda 9.0 supports only GCC 6.0 and below, and Ubuntu 18.04 has a pre-installed GCC version of 7.3,
So manually downgrade:
Step. 1 GCC downgrade
Since Cuda 9.0 supports only GCC 6.0 and below, and Ubuntu 18.04 has a pre-installed GCC version of 7.3,
So manually downgrade:
sudo apt-get install gcc-4.8 sudo apt-get install g++-4.8
After loading, enter into the/usr/bin directory
The following results are displayed
lrwxrwxrwx 1 root root 7th 18:16/USR/BIN/GCC-gcc-7.3
Discover that GCC is linked to gcc-7.0 and need to change it to link to gcc-4.8 as follows:
sudo mv gcc gcc.bak #备份 sudo ln-s gcc-4.8 gcc #重新链接
Similarly, the same changes are made to g++:
Ls-l g++* lrwxrwxrwx 1 root root 7th May 15:17 g++-g++-7.3
You need to change the g++ link to g++-4.8:
sudo mv g++ g++.bak sudo ln-s g++-4.8 g++
View gcc and g++ version numbers again:
g++-V
均显示gcc version 4.8 ,说明gcc 4.8安装成功。
Step. 2 installation Cuda, and its patches
Enter the command to install base Installer:
sudo sh cuda_9.1.85_387.26_linux.run
It is important to note that the video driver has been installed before, so when asked whether to install the video driver to select No, the other select the default path or Yes.
Then, continue with the following installation of 3 patches:
sudo sh cuda_9.1.85.1_linux.runsudo sh cuda_9.1.85.2_linux.runsudo sh cuda_9.1.85.3_linux.run
After installation, add the following two strips to the .barshrc
file.
Export path=/usr/local/cuda-9.1/bin${path:+: $PATH}} #注意, modify Cuda-9.2/9.0...export according to your version ld_library_path=/usr /local/cuda-9.1/lib64${ld_library_path:+:${ld_library_path}} #注意, modify the cuda-9.2/9.0 according to your own version ...
OK, so, to this step, Cuda installs the complete
Confirm Cuda Work
Found samples
, usually in the home
directory
CD ~/nvidia_cuda-9.1_samples/make
Wait for the compilation to complete,
Using deviceQuery
Tests
$./devicequery./devicequery Starting ... Cuda device Query (Runtime API) version (Cudart static linking) detected 1 CUDA capable device (s) device 0: "GeForce GTX 960 M "Cuda Driver version/runtime version 9.1/9.1 CUDA Capability major/minor version number:5.0 total am Ount of global memory:2004 MBytes (2101870592 bytes) (5) multiprocessors, (+) CUDA cores/mp:640 CUDA cores GPU Max Clock rate:1176 MHz (1.18 GHz) Memory Clock rate: 2505 Mhz Memory Bus width:128-bit L2 Cache size:2097 Bytes Maximum Texture Dimension Size (x, Y, z) 1d= (65536), 2d= (65536, 65536), 3d= (4096, 4096, 4096) Maximum La yered 1D Texture size, (num) layers 1d= (16384), 2048 layers Maximum layered 2D Texture Size, (num) layers 2d= (16384, 16 384), 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:65536 Warp size: Maximum number of threads per multiprocessor:2048 Maximum number of threads per block:1024 Max dimension size of a thread block (x, Y, z): Max dimension size of a grid size (x, Y, z): (2147483647 , 65535, 65535) Maximum memory pitch:2147483647 bytes Texture alignment: Bytes Concurrent copy and kernel Execution:yes with 1 copy engine (s) Run time limit on kernels: Yes Integrated GPU Sharing host Memory:no support host page-locked Memory Mapping:ye S Alignment requirement for surfaces:yes device have ECC support:disabled device sup Ports Unified Addressing (UVA): Yes Supports Cooperative Kernel launch:no Supports Multidevice Co-op Ke Rnel Launch:no DeVice PCI Domain id/bus id/location id:0/1/0 Compute Mode: < Default (multiple host threads can use:: CU Dasetdevice () with device simultaneously) >devicequery, cuda Driver = Cudart, cuda Driver Version = 9.1, Cuda Runtime V Ersion = 9.1, Numdevs = 1Result = PASS
3. Installing the CUDNN (for 18.04)
The installation of CuDNN is to copy the files in the CuDNN package to the Cuda folder.
STEP.1 following the 4th analysis, we need to download the CUDNN version for
CuDNN v7.0.5 Library for Liunx (requires registration to download)
After downloading, cut to the default downloads folder, you can see the cudnn-9.1-linux-x64-v7.tgz compressed package
Unzip and then copy the contents into the Cuda installation folder.
STEP.2 copying CUDNN content into Cuda-related folders
sudo cp cuda/include/cudnn.h /usr/local/cuda/include #注意, after extracting the folder name Cuda, copy the corresponding file to the Cuda in/usr/local in sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r/usr/local/cuda/include/cudnn.h /usr/local/cuda/ lib64/libcudnn*
Here, so the installation is complete.
Next, you can install the appropriate software, such as: Anaconda,pycharm TensorFlow ...
Installation in Ubuntu16.04 environment:
Installing Nvdia Drivers and Cuda:
The following blog is the main reference
63251725
Here is a link to all Cuda versions of the Web page
Https://developer.nvidia.com/cuda-toolkit-archive
Then the CD command enters/usr/local/cuda/samples and executes the following command to build samples
sudo make all-j64
After all the compilation is complete, the CD enters
Into/usr/local/cuda/samples/bin/x86_64/linux/release, run Devicequery
./devicequery
If the video card information appears, the driver and the video card installation is successful, the result is as follows:
Install CUDNN:
After downloading the CUDNN compressed package, follow the steps below to install it:
1. Remove some files from the original CUDNN system path
sudo rm-rf/usr/local/cuda/include/cudnn.hsudo rm-rf/usr/local/cuda/lib64/libcudnn* #这里 * is a wildcard character, libcudnn* Refers to all files with LIBCUDNN in the name
2, install just unzip the CUDNN version, in the terminal CD to just unzip the Cuda folder, and then continue to enter the following two instructions, these two instructions are equivalent to the extracted Cuda folder under the files copied to the system path below
sudo cp include/cudnn.h/usr/local/cuda/include/sudo CP lib64/lib*/usr/local/cuda/lib64/ #这里 * is a wildcard character, lib* Refers to all files with Lib in the name
3, in the system path to establish a soft link (extracted lib64 below there are 3 so files. respectively is
Libcudnn.so and libcudnn.so.5 as well as libcudnn.so.5.1.3 files. And these 3 point so file sizes are the same. In fact, they are soft connections! Libcudnn.so links to Libcudnn.so.5, while
Libcudnn.so.5. Also linked to libcudnn.so.5.1.3. Real files are only
libcudnn.so.5.1.3)
Cd/usr/local/cuda/lib64sudo chmod +r libcudnn.so.5.1.10sudo ln-sf libcudnn.so.5.1.10 libcudnn.so.5sudo ln-sf libcudnn. So.5 libcudnn.so
Next, set the environment variables:
sudo gedit/etc/profile
Add the following two words to the open file
Export Path=/usr/local/cuda/bin: $PATHexport ld_library_path=/usr/local/cuda/lib64: $LD _library_path
After saving, make the environment variable take effect immediately,
Source/etc/profile
Install nvidia drivers, CUDA, CUDNN on Ubuntu