- the lasterst install reference:Ubuntu1604+CUDA9.0+Cudnn7.5+Caffe+digits
- 1 [TitanX Stepup and Issue]
- 2 [CUDA Version]
- CUDA-9.0
$ 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)
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}
$ sudo apt-get install cuda-drivers
$ sudo reboot
then you can try again key "nvidia-smi"
$ 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
$ 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
$ 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
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
////=========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
If you have more than two GPU
$ git clone https://github.com/NVIDIA/nccl.git
$ cd nccl
$ sudo make install -j4
$ 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
$ 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)
set( OpenCV_DIR "/home/ubuntu/opencv-2.4.13/release/" ) ###
find_package(OpenCV REQUIRED) ###
$ 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
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
$ 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
$ 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
$ cd caffe
$ sh data/mnist/get_mnist.sh
$ sh examples/mnist/create_mnist.sh
$ sh examples/mnist/train_lenet.sh
$ su
進到root權限,再重複執行
$ 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.
$ echo $SHELL
/bin/bash
$ echo $CAFFE_ROOT
$ echo "export CAFFE_ROOT=/home/username/caffe/" >> ~/.profile
$ source ~/.profile
$ echo $CAFFE_ROOT
/home/username/caffe/
$ su
進到root權限,再重複執行