James K J
James K J

Reputation: 615

Opencv4.2.0 with Nvidia GPU installation issue in ubuntu 20.04

I wanted to build opencv with gpu and the tutorial i particularly followed was Tutorial Link. Every time I build opencv with gpu using cmake, I come across the below error.

     usr/bin/x86_64-linux-gnu-ld: cannot find -llib64
     collect2: error: ld returned 1 exit status
     make[2]: *** [modules/cudev/CMakeFiles/opencv_cudev.dir/build.make:86:
     lib/libopencv_cudev.so.4.2.0] Error 1
     make[1]: *** [CMakeFiles/Makefile2:5326: modules/cudev/CMakeFiles/opencv_cudev.dir/all] Error 2
     make[1]: *** Waiting for unfinished jobs....

After referring many posts, some say it has to do with opencv.cmake, while others it has to be with the compiler. link1,link2link3. I am still stuck and couldn't make any progress for couple of days. If you have come across such error, please help me on how to solve it.

The config i am using

Graphic Card: NVIDIA GTX 1070

cuda library: cuda10.1

compiler: g++-6

python: 3.8

operating system: ubuntu20.04

The command I used to build it is given below

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/opt/opencv \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D WITH_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D CMAKE_C_COMPILER=/usr/bin/gcc-6 \
    -D CMAKE_CXX_COMPILER=/usr/bin/g++-6 \
    -D OPENCV_DNN_CUDA=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D CUDA_ARCH_BIN=6.1 \
    -D CUDNN_INCLUDE_DIR=/usr/lib/cuda/include \
    -D CUDNN_LIBRARY=/usr/lib/cuda/lib64 \
    -D WITH_CUBLAS=1 \
    -D OPENCV_EXTRA_MODULES_PATH=/home/james/Installers/opencv/opencv_contrib/modules \
    -D HAVE_opencv_python3=ON \
    -D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python \
    -D PYTHON_DEFAULT_EXECUTABLE=<path/to/desired/python/environment>/bin/python3.5
    -D PYTHON_INCLUDE_DIRS=<path/to/desired/python/environment>/include/python3.5m
    -D PYTHON_EXECUTABLE=<path/to/desired/python/environment>/bin/python3.5
    -D PYTHON_LIBRARY=<path/to/desired/python/environment>libpython3.5m.so.1
    -D BUILD_EXAMPLES=ON ..

nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Sun_Jul_28_19:07:16_PDT_2019 Cuda compilation tools, release 10.1, V10.1.243

Any tips would be greatly helpful .

Upvotes: 0

Views: 844

Answers (1)

mutex2201
mutex2201

Reputation: 1

i replace all -llib64 to -L/usr/local/cuda/lib64 -lcudnn using find and sed in build opencv dir:
find -name link.txt -exec sed -i -e 's/-llib64/-L\/usr\/local\/cuda\/lib64 -lcudnn/g' {} \;

Upvotes: 0

Related Questions