Skip to content

L706077/Nvidia-GPU-Install-and-Setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 

Repository files navigation

Nvidia-GPU-Install-and-Setup


brfore startup GPU you need to install Opencv2.4.13

Step1

if GPU card be installed on Workstation:

$ lspci | grep -i NVIDIA

if termainal show : VGA compatible controller: NVIDIA Corporation Device 1b00 (rev a1)
you can try sa following:

$ sudo update-pciids

then you can see : VGA compatible controller: NVIDIA Corporation GP102 [TITAN X] (rev a1)

Step2

install CUDA as following:

Using "cuda8.0" version for example:

$ CUDA_REPO_PKG=cuda-repo-ubuntu1604_8.0.61-1_amd64.deb

$ wget -O /tmp/${CUDA_REPO_PKG} http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}

$ sudo dpkg -i /tmp/${CUDA_REPO_PKG} 

$ sudo apt-get update

$ sudo apt-get install cuda-8-0

$ nano ~/.bashrc
 export CUDA_HOME=/usr/local/cuda-8.0
 export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
 export PATH=${CUDA_HOME}/bin:${PATH}

Using "cuda9.0" version for example:

$ sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb

sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
$ sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub

$ sudo apt-get update

$ sudo apt-get install cuda

$ nano ~/.bashrc
 export CUDA_HOME=/usr/local/cuda-9.0
 export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
 export PATH=${CUDA_HOME}/bin:${PATH}

add in the end, then enter "ctrl+x" to save

$ source ~/.bashrc

$ sudo reboot

than update cuda driver:

$ sudo ubuntu-drivers autoinstall

then you can try key "nvcc -V" can see:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

$ rm -f /tmp/${CUDA_REPO_PKG}

if key "$ nvidia-smi" show no driver:

$ sudo apt-get install cuda-drivers

$ sudo reboot

then you can try again key "nvidia-smi"

Run CUDA Sample Code:

$ cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
$ sudo make
$./deviceQuery

then you can see everything basic GPU information about your GPU card


If you meet login loop problem, you can key 'Ctrl + Alt + F1' to terminal mode than:

$ nvidia-smi

if show no drivers, then you can try as follow cammand:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo ubuntu-drivers autoinstall


Step3.0

Install TensorRT3

$ sudo dpkg -i nv-tensorrt-repo-ubuntu1604-ga-cuda9.0-trt3.0.4-20180208_1-1_amd64.deb

$ sudo apt-get update

$ sudo apt-get install tensorrt

$ dpkg -l | grep TensorRT

Step3.1

Install cuDNN 5.1:

According your CUDA Version then choose cuDNN v5.1 Library for Linux to download

$ cd 下載

$ tar xvzf cudnn-8.0-linux-x64-v5.1.tgz
$ tar xvzf cudnn-8.0-linux-x64-v6.0.tgz

$ sudo cp -P cuda/include/cudnn.h /usr/local/cuda-8.0/include 

$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64

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

ignore temporatory

create soft link:

////=========cudnn5.1=========
$ sudo ln -s libcudnn.so.5.1.10 libcudnn.so.5

$ sudo ln -s libcudnn.so.5 libcudnn.so

////=========cudnn7.0=========

$ sudo ln -s libcudnn.so.7.0.5 libcudnn.so.7

$ sudo ln -s libcudnn.so.7 libcudnn.so

ignore temporatory

Step4

insatll NCCL

If you have more than two GPU

$ git clone https://github.com/NVIDIA/nccl.git

$ cd nccl

$ sudo make install -j4

Step5

install caffe:

$ git clone https://github.com/BVLC/caffe.git

$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

$ sudo apt-get install --no-install-recommends libboost-all-dev

$ sudo apt-get install libatlas-base-dev 

$ sudo apt-get install libopenblas-dev
 
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

$ sudo apt-get install -y python-pip
//=== python2.7 ===
$ sudo apt-get install -y python-dev

$ sudo apt-get install -y python-numpy python-scipy
//=== python3.5 ===
$ sudo apt-get install -y python3-dev

$ sudo apt-get install -y python3-numpy python3-scipy
//=================
$ cd caffe/python/

$ for req in $(cat requirements.txt); do sudo -H pip install $req --upgrade; done

$ sudo apt-get update

$ cp Makefile.config.example Makefile.config

Open Makefile.config to change:

# USE_CUDNN := 1   ---->   USE_CUDNN := 1
# CUDA_DIR := /usr/local/cuda   ---->   CUDA_DIR := /usr/local/cuda-8.0
# INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
# LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
# PYTHON_INCLUDE := /usr/include/python2.7 /usr/lib/python2.7/dist-packages/numpy/core/include
attantion to check /usr/lib/python2.7  or  /usr/local/lib/python2.7


The build process will fail in Ubuntu 16.04. Edit the Makefile with an editor such as

$ nano ./Makefile

and replace this line:

 NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

*with the following line:

NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

Also, open the file CMakeLists.txt and add the following line:

# ---[ Includes
set(${CMAKE_CXX_FLAGS} "-D_FORCE_INLINES ${CMAKE_CXX_FLAGS}")

(See the discussion at: BVLC/caffe#4046)

add opencv dependency requires in caffe "CMakeLists.txt" file as follows:

set( OpenCV_DIR "/home/ubuntu/opencv-2.4.13/release/" ) ###
find_package(OpenCV REQUIRED) ###

create caffe thirdparty lib symbolic link:

$ cd /usr/lib/x86_64-linux-gnu

$ sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so

$ sudo ln -s libhdf5_serial.so.10.1.0 libhdf5_hl.so

if you need to delete symbolic link:

$ rm -rf /usr/lib/x86_64-linux-gnu/libhdf5_hl.so /usr/lib/x86_64-linux-gnu/libhdf5_serial_hl.so.10.1.0

$ rm -rf /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.10.1.0 /usr/lib/x86_64-linux-gnu/libhdf5.so

make caffe:

the new version method

$ cd caffe

$ mkdir build

$ cmake ..

$ make all

$ make runtest

$ nano ~/.bashrc
export PYTHONPATH=/home/ubuntu/caffe/python/:$PYTHONPATH

$ source ~/.bashrc

then you can try as following cammand

$ python
>>> import caffe

配置pycaffe:

$ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags cython ipython

$ sudo apt-get install protobuf-c-compiler protobuf-compiler

$ cd ~/caffe/build

$ make pycaffe

ignore tmp

$ sudo gedit /etc/profile # 末尾添加: export PYTHONPATH = caffe目录下的python地址:$PYTHONPATH,用完整路径,不要用~

for example:
export PYTHONPATH=/home/ubuntu/caffe/python/:$PYTHONPATH

$ source /etc/profile # 使之生效

ignore tmp


$ nano ~/.bashrc
export PYTHONPATH=/home/ubuntu/caffe/python/:$PYTHONPATH

$ source ~/.bashrc

$ cd caffe

$ make distribute

test caffe in python

$ python
>>>import caffe

If show:

>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named caffe

then

$ nano ~/.bashrc
export PYTHONPATH=/home/ubuntu/caffe/distribute/python/:$PYTHONPATH

$ source ~/.bashrc

使用MNIST数据集进行测试:

$ cd caffe
$ sh data/mnist/get_mnist.sh
$ sh examples/mnist/create_mnist.sh
$ sh examples/mnist/train_lenet.sh

如果出現Check failed : status == CUDNN_STATUS_SUCCESS (4 vs. 0) CUDNN_STATUS_INTERNAL_ERROR

$ su
進到root權限,再重複執行

Step6

Install Digits:

$ DIGITS_ROOT=~/digits

$ git clone https://github.com/NVIDIA/DIGITS.git $DIGITS_ROOT

$ sudo pip install -r $DIGITS_ROOT/requirements.txt

$ sudo pip install -e $DIGITS_ROOT

$cd digits

$./digits-devserver

Starts a server at http://localhost:5000/

If show A valid Caffe installation was not found on your system. Use the envvar CAFFE_ROOT to indicate a valid installation.

These instructions are for bash

$ echo $SHELL
/bin/bash

Check the current value of your envvar

$ echo $CAFFE_ROOT

Add the envvar to ~/.profile so it will load automatically when you login

$ echo "export CAFFE_ROOT=/home/username/caffe/" >> ~/.profile

Load the new configuration

$ source ~/.profile

Check the new envvar value

$ echo $CAFFE_ROOT
/home/username/caffe/

如果出現Check failed : status == CUDNN_STATUS_SUCCESS (4 vs. 0) CUDNN_STATUS_INTERNAL_ERROR

$ su
進到root權限,再重複執行

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published