Instructions are completely incomprehensible to someone not used to compiling massive C++ programs from source and i am reduced to finding outdated posts on random forums to try, waste hours compiling, then fail. Someone PLEASE post a clear guide or script to achieve this to save me and everyone time in the future…
Are you using Windows or Linux, if Windows detailed instructions can be found by following the link below
1 Like
Linux. An issue was opened here.
opened 04:51AM - 10 Aug 23 UTC
incomplete
### System Information
OpenCV version: 4.7.0
Operating System / Platform: Li… nux Mint 20.3
Compiler & compiler version: GCC 9.4.0
CUDA version: 12.0
### Detailed description
Due to being forced to manually compile opencv for python to use CUDA and having absolutely no knowledge of Cmake/C++ compilation/libraries/linking/what have you, i am trying to install this using this script i found online, as it's the only way i can.
```#!/bin/bash
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y build-essential cmake git unzip pkg-config make libjpeg-dev libpng-dev libtiff-dev libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y python3.8-dev python3-numpy libtbb2 libtbb-dev
sudo apt-get install -y libdc1394-22-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtbb-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libavutil-dev libavfilter-dev libavresample-dev
mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv
git clone https://github.com/opencv/opencv_contrib
cd ~/opencv_build/opencv
mkdir -p build && cd build
cmake -D WITH_CUDA=ON -D CUDA_VERSION=12.0 -D WITH_CUBLAS=ON -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D BUILD_TIFF=ON -D BUILD_opencv_java=OFF -D WITH_OPENGL=ON -D WITH_OPENCL=ON -D WITH_IPP=ON -D WITH_TBB=ON -D WITH_EIGEN=ON -D WITH_V4L=ON -D WITH_VTK=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python2=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D PYTHON3_EXECUTABLE=$(which python3) -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..
make -j8
sudo make install
sudo ldconfig
pkg-config --modversion opencv4
```
After compiling, importing cv2 in python yields this error:
```Traceback (most recent call last):
File "yolo.py", line 1, in <module>
import cv2
File "/home/anon/.local/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/home/anon/.local/lib/python3.8/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libnppc.so.11: cannot open shared object file: No such file or directory
```
### Steps to reproduce
Use the included script
### Issue submission checklist
- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)