# CentOS 7 Environment Configuration

## 1. Check GPU device recognition

```
  $ yum install pciutils
  $ sudo lspci | grep NVIDIA
  3D controller: NVIDIA Corporation GK210GL [Tesla K80] indicates recognition as K80
  3D controller: NVIDIA Corporation Device 1b38 (rev a1) indicates P40
```

## 2. Obtain the cuda network source and configure it

The official source address of NVidia is http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/
```
  $ wget http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-8.0.61-1.x86_64.rpm
  $ rpm -Uvh cuda-repo-rhel7-8.0.61-1.x86_64.rpm
```
Note: Installing the nvidia driver requires the kernel-devel package, which can be installed as follows:
```
  $ wget http://vault.centos.org/7.0.1406/updates/x86_64/Packages/kernel-devel-3.10.0-123.4.4.el7.x86_64.rpm
  $ wget http://vault.centos.org/7.0.1406/updates/x86_64/Packages/kernel-headers-3.10.0-123.4.4.el7.x86_64.rpm
  $ rpm -Uvh kernel-devel-3.10.0-123.4.4.el7.x86_64.rpm
  $ rpm -Uvh kernel-headers-3.10.0-123.4.4.el7.x86_64.rpm
```
## 3. Install cuda 8.0

  $ yum install cuda-8-0

### 3.1 Check driver status
```
$ sudo nvidia-smi
```

## 4. Test the basic GPU functionality (optional)

### 4.1 Add LD path
<code>
$ export LD_LIBRARY_PATH="/usr/local/cuda-7.5/lib64:/usr/lib64/:$LD_LIBRARY_PATH"
</code>

### 4.2 Install cuda examples

```
  $ cd /usr/local/cuda/bin
  $ sh cuda-install-samples-8.0.sh ~/cuda-test/
  $ cd ~/cuda-test/NVIDIA_CUDA-8.0_Samples
  $ make
  $ ./bin/x86_64/linux/release/deviceQuery To get device status
  $ ./bin/x86_64/linux/release/bandwidthTest To test the device bandwidth
```

Note: If a lnvcuvid error is found during the compiling process, run:

<code>
$ find . -type f -execdir sed -i 's/UBUNTU_PKG_NAME = "nvidia-367"/UBUNTU_PKG_NAME = "nvidia-375"/g' '{}' \  
</code>

 Nvidia-375 is the current installed driver version

## 5. Install cudnn

Optional. Note: Different AI frameworks support different versions of cudnn

### 5.1 Download cudnn software package
[](https://developer.nvidia.com/cudnn), registration of nvidia account is required for downloading.

Note: Download cuDNN v5.1 Library for Linux for CentOS
         
### 5.2 Installation
Case Usage: cuDNN v5.1 (used because TensorFlow currently only supports v5.1)
<code>
$ tar -zxf cudnn-8.0-linux-x64-v5.1.tgz 
</code>

Extraction Path: Freely selectable (typically under /usr/lib). Assume the path is set as:
<code>
$ export LD_LIBRARY_PATH=:$LD_LIBRARY_PATH
</code>

## FAQ

### 1. Why does nvidia-smi find the GPU usage is 100%?

This problem is due to the system's inaccurate reading of GPU status. Executing the following command can correct it and allow the system to read the command correctly.
<code>
\# nvidia-smi -pm 1
</code>
