ubuntu16.04怎么默认使用python3.5
ubuntu16.04 have python2.7 and python3.5 installed. I personally tend to use python3.5, so I choose to set python3.5 as default IDE.
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
Install Opencv3.2.0
-
In order to save time, it is highly suggested to download Opencv3.2.0 and Opencv_contrib-3.2.0 from local mirrors.
-
Install dependent packages with reference in below links.
Reference Links:
https://blog.csdn.net/jiandanjinxin/article/details/71438780
https://www.cnblogs.com/kanuore/p/7587434.html
https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/ -
No need hurry to get Opencv_contrib3.2.0 installed.You can install Opencv3.2.0 first. If succeed, then go next steps.(But for YOLO3, when you use GPU and CUDA, Opencv_contrib-3.2.0 should be installed)
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
- Or you can also install opencv_contrib-3.2.0 at the same time after you have CUDA installed:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules -D WITH_CUDA=ON -D
CUDA_GENERATION=Kepler..
- Build and install
make -j4
sudo make install
sudo ldconfig
Issue – How to build with both python2 & python3
I delete opencv-3.2.0 and reinstall opencv-3.2.0 with python3.
Issue – Cannot import cv2 in python3
Reference Links:
https://blog.csdn.net/fanzhiyi521/article/details/53456169
Solution:
rename cv2.cpython-35m-x86_64-linux-gnu.so to cv2.so
cd /usr/local/lib/python3.5/dist-packages/
sudo mv cv2.cpython-35m-x86_64-linux-gnu.so cv2.so

Issue-Cmake问题:CMake Error at cmake/OpenCVUtils.cmake:1043 (file)
Reference Links:
https://blog.csdn.net/lulumi2016/article/details/77984546
Solution:
I download 3.2.0 from https://github.com/google/protobuf/releases but it seems related to internet speed.
If you install opencv & opencv_contrib with CUDA 9.1 , then you may see below alarms:
Issue - CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:CUDA_nppi_LIBRARY (ADVANCED)
Reference Links:
https://blog.csdn.net/u014613745/article/details/78310916
Solution:
CUDA9.1 not compatible with Opencv3.2. Actually I finally choose to use CUDA8.0...
Issue - nvcc fatal : when make, alarm: Unsupported gpu architecture 'compute_20'
This alarm happens when cmake with CUDA.
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules -D WITH_CUDA=ON
Reference Links:
https://stackoverflow.com/questions/48383846/nvcc-fatal-unsupported-gpu-architecture-compute-20-while-cuda-9-1caffeopen

Solution:
CUDA 9.1 does not support compute_20 anymore, so I finally choose to use CUDA8.0...
ubuntu16安装gpu加速(cuda8及NVIDIA显卡安装)
Reference Links:
https://blog.csdn.net/u011128775/article/details/72850497
Solution:
- Disable nouveau and add it to blacklist.conf.
查看属性
sudo ls -lh /etc/modprobe.d/blacklist.conf
修改属性
sudo chmod 666 /etc/modprobe.d/blacklist.conf
用gedit打开
sudo gedit /etc/modprobe.d/blacklist.conf
在该文件最后添加:
blacklist nouveau
打开系统设置点击软件和更新,选择附加驱动,选择上面的显卡驱动,然后点击应用更改即可,完了之后重启
NVIDIA.png
- Download cuda8 & cudnn
I choose: cuda_8.0.61_375.26_linux.run, and install cudnn-8.0-linux-x64-v6.0.tgz & cudnn-8.0-linux-x64-v7.1.tgz
Reference Links: - https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal
- https://blog.csdn.net/zafir_410/article/details/73188228?utm_source=itdadao&utm_medium=referral
- https://blog.csdn.net/u011128775/article/details/72850497
sudo apt-get install libglu1-mesa-dev
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo sh cuda_8.0.61_375.26_linux.run
sudo vim ~/.bashrc
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
(输入:nvidia-smi,显示下面信息则说明正确安装了)

Unzip cudnn installations:
tar xvzf cudnn-8.0-linux-x64-v6.0.tgz
然后将库和头文件copy到cuda目录(一定是你自己安装的目录如/usr/local/cuda-8.0)
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*
cudnn复制完成之后,再输入(解决可能会出现的连接符错误):
sudo cp /usr/local/cuda-8.0/lib64/libcufft.so.8.0 /usr/local/lib/libcufft.so.8.0 && sudo ldconfig
sudo cp /usr/local/cuda-8.0/lib64/libcurand.so.8.0 /usr/local/lib/libcurand.so.8.0 && sudo ldconfig
sudo cp /usr/local/cuda-8.0/lib64/libcudnn.so /usr/local/lib/libcudnn.so && sudo ldconfig
sudo cp /usr/local/cuda-8.0/lib64/libcudnn.so.6 /usr/local/lib/libcudnn.so.6 && sudo ldconfig
sudo cp /usr/local/cuda-8.0/lib64/libcudnn.so.6.0.21 /usr/local/lib/libcudnn.so.6.0.21 && sudo ldconfig
I add more libcudnn.so files to /usr/local/lib to avoid related alarms.

Darknet:
Reference Links:
https://pjreddie.com/darknet/yolo/
- Download Darknet
git clone https://github.com/pjreddie/darknet
- Modify Makefile:
OPENCV=1 ; CUDA Version =8.0
- Build Darknet
cd Darknet
make

-Download weight file
wget https://pjreddie.com/media/files/yolov3.weights
-
Test a image:
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
dog.png
-
Test Real-Time Detection on a Webcam:
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights
video.png
-
Test a video <后来的我们>
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights movie.mp4

Long time passed since I did the test, many alarms occurred during installation. I did it just for fun, and still many things to learn. Here just to record the issues that I met in case I need to do same work in the future. If anything wrong, I will appreciate your feedback.
-- the End--
网友评论