Ubuntu + CUDA9.1 + CUDNN7.1.2 + OpenCV3.4.1 + contrib-master +CAFFE-master

Praise Rufus when installing ubuntu 14.04, refer to https://www.cnblogs.com/willnote/p/6725594.html for the process

-------------------------------------------------- ---------
! Save! barrier! network! network! Pass! smooth!
-------------------------------------------------- ---------
Install graphics card driver
sudo gedit /etc/modprobe.d/blacklist-nouveau.conf
    blacklist nouveau
sudo update-initramfs -u
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt- get update 
shutdown
power on
ctrl+alt+F1 to enter the command line mode and log in as a user.
sudo apt-get remove --purge nvidia* 
sudo service lightdm stop 
sudo apt-get install nvidia-xxx #Refer to NVIDIA official website for the specific version
#Or sudo sh [path]/NVIDIA-Linux-x86_64-xxx.xx.run
sudo service lightdm start
restart
sudo nvidia-smi #Confirm that valid information is output
----------------------------------- ------------------------
------------------------ ---------------------------------
Install dependencies 
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libopenblas-dev liblapack-dev libatlas-base-dev libgflags-dev libgoogle-glog-dev liblmdb-dev -y
-------------------------------------------------- ---------
----------------------------------------- ------------------
Install
the CUDA and CUDNN versions supported by the cuda graphics card, refer to the NVIDIA official website
sudo sh ./cuda_9.1.85_387.26_linux.run 
sudo sh ./cuda_9.1.85.1_linux.run 
sudo sh ./cuda_9.1.85.2_linux.run 
sudo sh ./cuda_9.1.85.3_linux.run 
sudo gedit ~/.bashrc
    export PATH=/usr/local/cuda-[version number]/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-[版本号]/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
-------------------------------------------------- ---------
test cuda 

cd [NVIDIA_CUDA_SAMPLES]/1_Utilities/deviceQuery
sudo make
./deviceQuery #Confirm that valid graphics card information is output

----------------------------------------------------------- 
sudo cp [cudnn]/cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp [cudnn]/cuda/lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.[major version number]
sudo ln -s libcudnn.so.[full version number] libcudnn.so.[major version number]
sudo ln -s libcudnn.so.[major version number ] libcudnn.so
sudo ldconfig
-------------------------------------------- ---------------
----------------------------------- ------------------------
Install opencv-3.4.1 + contrib-master
contrib extract to [opencv]/modules/
download ippicv_2017u3_lnx_intel64_general_20170822.tgz to [opencv ] ]/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e renamed 4e0352ce96473837b1d671ce87f17359-ippicv_2017u3_lnx_intel64_general_20170822.tgz

cmake:
    BUILD_DOCS BUILD_JPEG BUILD_PNG BUILD_opencv_world OPENCV_EXTRA_MODULES_PATH([contrib]/modules)
configure twice to confirm that it is correct (or related BLAS errors, no negative effects have been found so far) and then generate

cd [opencv]/build
sudo make all -j[number of cores]
sudo make install -j[number of cores]
sudo gedit /etc/ld.so.conf.d/opencv.conf
    /usr/local/lib/x86_64-linux -gnu
sudo ldconfig
---------------------------------------------- -------------
------------------------------------- ----------------------
Install caffe
Copy caffe/MakeFile.config.example to MakeFile.config
     USE_CUDNN := 1
     USE_OPENCV := 1

    # Whatever else you find you need goes here.
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/include/opencv /usr/local/include/opencv2 /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 /usr/local/lib/x86_64-linux-gnu
    CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \
                 #-gencode arch=compute_20,code=sm_21 \

MakeFile note that the spaces are replaced by tabs:
ifeq ($(USE_OPENCV), 1)
#LIBRARIES += opencv_core opencv_highgui opencv_imgproc
#ifeq ($(OPENCV_VERSION), 3)
#LIBRARIES += opencv_imgcodecs
#endif
LIBRARIES += opencv_world
endif

make all -j[CPU内核数]
sudo gedit /etc/ld.so.conf.d/caffe.conf
    /usr/local/cuda/lib64
sudo ldconfig
 
-------------------------------------------------- ---------
----------------------------------------- ------------------
test caffe
cd [caffe]
sudo sh data/mnist/get_mnist.sh
sudo sh examples/mnist/create_mnist.sh
sudo sh examples/mnist/train_lenet.sh 
-----------------------------------------------------------
-----------------------------------------------------------
Refer to  http://www.cnblogs.com/denny402/p/5083300.html to  start construction

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324414598&siteId=291194637