ubuntu16.4+cuda+cudnn+opencv3.3+tensorrt3.0安装及部分问题


# cuda9.0
sudo apt-get purge cuda
sudo apt-get purge libcudnn6
sudo apt-get purge libcudnn6-dev


wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb

 

wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb

 

 

sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo apt-get update
sudo apt-get install cuda=9.0.176-1
sudo apt-get install libcudnn7-dev
sudo apt-get install libnccl-dev


-----
Reboot the system to load the NVIDIA drivers.


Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables, also add them to the end ofd .bashrc file
-----


export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}


# 安装cudnn
官方教程:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html
下载: https://developer.nvidia.com/rdp/cudnn-download
解压: tar -xzvf cudnn-9.0-linux-x64-v7.tgz


$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include  # 拷贝文件
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*




# OpenCV33  
环境介绍: ubuntu16+cuda9.0+gtx1080+python3.5+cmake3.5.1
官网安装教程: https://docs.opencv.org/3.3.0/d7/d9f/tutorial_linux_install.html
查看适合自己的安装的版本:pkg-config --modversion opencv
下载文件: https://opencv.org/opencv-3-3.html
解压: tar -xvf opencv-3.3.0.tar.gz


下载opencv_contrib-3.3.0  :https://github.com/opencv/opencv_contrib
解压:~/opencv_contrib-3.3.0


cd opencv-3.3.0
mkdir build
cd build


# cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D ENABLE_CXX11=ON -D WITH_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv-3.3.0/opencv_contrib-3.3.0/modules -D BUILD_SHARED_LIBS=ON -D WITH_GTK=ON -D BUILD_EXAMPLES=ON -D PYTHON_EXECUTABLE=/usr/bin/python3.5 -D BUILD_WITH_DEBUG_INFO=OFF -D CMAKE_C_COMPILER=/usr/bin/gcc-5 -D ENABLE_PRECOMPILED_HEADERS=OFF ..


cmake出错,查看/build/CMakeFiles/CMakeError.log文件里error的地方是not support c++11问题,解决方法在cmake加入几句(上面已经加了):
-D CMAKE_C_COMPILER=/usr/bin/gcc-5
-D ENABLE_CXX11=ON
-D ENABLE_PRECOMPILED_HEADERS=OFF


又出错:/home/dyz/opencv-3.3.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: 没有那个文件或目录
这里是用cuda编译的问题 把上面cmake -D WITH_CUDA=ON 改为-D WITH_CUDA=OFF再次编译就可以了


# make
make -j4 
sudo make install


Done


安装完pkg-config --modversion opencv 查看版本信息

# 这样默认的安装目录在/usr/local/share下有个Opencv的文件夹

# 同时安装opencv2和opencv3可以参考:https://blog.csdn.net/MD2017/article/details/81235066

'''


# tensorRT3.0
下载deb:https://developer.nvidia.com/nvidia-tensorrt-download
sudo dpkg -i nv-tensorrt-repo-ubuntu1604-ga-cuda9.0-trt3.0.2-20180108_1-1_amd64.deb
sudo apt-get update
sudo apt-get install tensorrt




sudo apt-get install python3-libnvinfer-doc
# 查看 dpkg -l | grep TensorRT

你可能感兴趣的:(ubuntu,python,Machine,Learning)