使用UltraISO制作安装盘会出现问题,建议使用Rufu制作安装盘。
sudo add-apt-repository ppa:graphics-drivers
sudo apt update
sudo apt install nvidia-396
sudo reboot now
重启后在settings→Software & Updates→Other Software中将源删除;在/etc/apt/sources.list.d中将对应文件删除,避免自动升级驱动。
正确选择CUDA、cuDNN版本号,建议CUDA使用runfile版,cuDNN使用Library版安装
//CUDA
sudo chmod +x (CUDA安装文件名)
./(CUDA安装文件名) //询问是否安装GPU驱动时选择“n”,切记不要重复安装GPU驱动
sudo vim ~/.bashrc
//在文件结尾加入如下两行
export PATH=/usr/local/cuda-9.2/bin${PATH:+:$PATH}} //注意,根据自己的版本,修改cuda-9.2/9.0...
export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} //注意,根据自己的版本,修改cuda-9.2/9.0...
//cuDNN
tar -xzvf (cuDNN安装文件名)
cd CUDA
sudo cp include/cudnn.h /usr/local/cuda/include
sudo cp lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
//关闭终端,重新打开终端
nvcc -V
//如果显示nvcc版本,则说明安装成功
安装pip时用如下命令安装:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
//下载源码
git clong https://github.com/opencv/opencv.git
git clong https://github.com/opencv/opencv_contrib.git
//切换版本
cd opencv
git checkout 3.4.0
cd ../opencv_contrib
git checkout 3.4.0
cd ../opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \ //使用GPU
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON -D PYTHON3_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python3=ON \
-D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so ..
make
sudo make install
若在cmake中出现如下错误
[proxychains] DLL init: proxychains-ng 4.13-git-3-geb36238
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_CUDA_LIBRARY (ADVANCED)
linked by target "example_gpu_optical_flow" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_houghlines" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_video_reader" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_surf_keypoint_matcher" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_cascadeclassifier_nvidia_api" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_alpha_comp" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_bgfg_segm" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_morphology" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_generalized_hough" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_farneback_optical_flow" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_stereo_multi" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_driver_api_multi" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_opticalflow_nvidia_api" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_hog" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_pyrlk_optical_flow" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_cascadeclassifier" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_driver_api_stereo_multi" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_super_resolution" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_multi" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_video_writer" in directory /home/bfyb/Downloads/opencv/samples/gpu
linked by target "example_gpu_stereo_match" in directory /home/bfyb/Downloads/opencv/samples/gpu
-- Configuring incomplete, errors occurred!
See also "/home/bfyb/Downloads/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/bfyb/Downloads/opencv/build/CMakeFiles/CMakeError.log".
则,在cmake的参数中添加如下:
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs
如果在cmake过程中,出现ffmpeg无法找到,
Can't find ffmpeg - 'pkg-config' utility is missing
...
-- Video I/O:
-- DC1394: NO
-- FFMPEG: NO
-- avcodec: NO
-- avformat: NO
-- avutil: NO
-- swscale: NO
-- avresample: NO
-- GStreamer: NO
通过
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
可以解决,具体原因参见这篇博客
install 完成后若想要删除,则
cd (opencv/build目录)
sudo make uninstall
cd ..
sudo rm -r build
git clone https://github.com/AlexeyAB/darknet.git
cd darknet
//根据条件设置Makefile文件中的GPU、CUDNN、CUDNN_HALF、OPENCV、AVX、OPENMP、LIBSO
vim Makefile
make
完成安装!!!
如果运行检测命令后出现如下错误:
./darknet ./darknet: error while loading shared libraries: libopencv_highgui.so.3.4: cannot open shared object file: No such file or directory
则参考这条issue进行如下修改:
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig