在Ubuntu上自己编译 opencv(+cuda)和dlib(+cuda)

install opencv

首先安装这些个依赖库
sudo apt-get install -y autoconf automake build-essential git libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev
sudo apt-get install libavformat-dev
sudo apt-get install libavcodec-dev
sudo apt-get install libswresample-dev
sudo apt-get install libswscale-dev
sudo apt-get install libavutil-dev
sudo apt-get install libsdl1.2-dev
sudo apt-get install libgtk-3-dev

1.sudo apt purge libopencv-dev libopencv-python libopencv-samples libopencv*
    sudo apt update
    
2.git clone https://github.com/opencv/opencv.git -b 4.3.0 --depth 1
   git clone https://github.com/opencv/opencv_contrib.git -b 4.3.0 --depth 1
       
3. cd opencv
    mkdir build && cd build

4. cmake 
    -DCMAKE_BUILD_TYPE=RELEASE     \
    -DCMAKE_INSTALL_PREFIX=/usr/local     \
    -DWITH_CUDA=ON     \
    -DWITH_GTK=ON     \
    -DINSTALL_C_EXAMPLES=OFF     \
    -DWITH_GSTREAMER=ON     \
    -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/     \
    -DOPENCV_ENABLE_NONFREE=ON     \
    -DBUILD_TESTS=OFF     \
    -DBUILD_PERF_TESTS=OFF     \
    -DINSTALL_PYTHON_EXAMPLES=ON     \
    -DPYTHON_EXECUTABLE=$(which python3)     \
    -DBUILD_opencv_python3=ON     \
    -DPYTHON3_EXECUTABLE=$(which python3)     \
   -DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")     \
   -DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")     \
   -DCUDA_ARCH_BIN="6.2"     \
   -DBUILD_NEW_PYTHON_SUPPORT=ON     \
   -DENABLE_FAST_MATH=1     \
   -DBUILD_TIFF=ON     \
   -DWITH_CUBLAS=1     \
   -DCUDA_FAST_MATH=1    \
   -DWITH_TBB=ON     \
   -DWITH_V4L=ON     \
   -DWITH_OPENGL=ON     \
   -DOPENCV_GENERATE_PKGCONFIG=YES ..

5. make -j8
    sudo make install
    sudo ldconfig

install dlib

1. sudo apt-get install libboost-all-dev

2. git clone https://github.com/davisking/dlib.git

3. cd dlib;      

    mkdir build; cd build
4. cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D DLIB_USE_CUDA=ON \
      -D CUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so \
      -D INSTALL_PYTHON_EXAMPLES=OFF \
      -D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
      -D INSTALL_C_EXAMPLES=OFF \
      -D OPENCV_EXTRA_MODULES_PATH=/home/nvidia/opencv_contrib/modules \
      -D BUILD_EXAMPLES=OFF ..
5. cmake --build . --config release -- -j6
6. sudo make install
7. sudo ldconfig

 

 

上述这些安装步骤,也同样适用于nVidia 的边缘计算平台环境的搭建。

如果想获取txt版本,可以关注它,获取下载链接:

在Ubuntu上自己编译 opencv(+cuda)和dlib(+cuda)_第1张图片

你可能感兴趣的:(深度学习,Computer,Vision,计算机视觉)