"OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA)" when building CV4

Hi,

I’m running into an issue building OpenCV 4 on my Xavier. Cmake can’t find CUDA.

Running nvcc --version I get:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_21:14:42_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

I can locate CUDA at /usr/local/cuda-8.0

My initial command was

cmake -D CMAKE_BUILD_TYPE=RELEASE \
	-D CMAKE_INSTALL_PREFIX=/usr/local \
	-D INSTALL_PYTHON_EXAMPLES=ON \
	-D INSTALL_C_EXAMPLES=OFF \
	-D OPENCV_ENABLE_NONFREE=ON \
	-D WITH_CUDA=ON \
	-D WITH_CUDNN=ON \
	-D OPENCV_DNN_CUDA=ON \
	-D ENABLE_FAST_MATH=1 \
	-D CUDA_FAST_MATH=1 \
	-D CUDA_ARCH_BIN=7.2 \
	-D WITH_CUBLAS=1 \
	-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
	-D HAVE_opencv_python3=ON \
	-D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python \
	-D BUILD_EXAMPLES=ON ..

After digging into the Cmake files, I discovered the param CUDA_BIN_PATH can be passed to specify the cuda path.

However, that still doesn’t work. I tried both as a param to the command and as an env var set before executing the command, it still won’t find CUDA.

I tried both CUDA_BIN_PATH=/usr/local/cuda-8.0 and CUDA_BIN_PATH=/usr/local/cuda-8.0/bin

I tried to build with and without a virtual env. I tried with and without sudo. Failing in all cases.

I have ran out of options to explore.

Here is the terminal output:

~/opencv/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_ARCH_BIN=7.2 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D HAVE_opencv_python3=ON -D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python -D BUILD_EXAMPLES=ON -D CUDA_BIN_PATH=/usr/local/cuda-8.0 ..
-- Detected processor: aarch64
-- Looking for ccache - not found
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3") 
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11") 
CMake Warning at cmake/OpenCVFindLibsPerf.cmake:35 (message):
  OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA).

  CUDA support will be disabled in OpenCV build.

  To eliminate this warning remove WITH_CUDA=ON CMake configuration option.

Anybody ran into this issues, or know what I could attempt to fix it?

Thanks!

seems to say that you have nvcc of CUDA 10.2. It should be located in /usr/local/cuda-10.2/bin

Usually a symbolic link /usr/local/cuda points to current version which should be cuda-10.2.

You may further tell about this conclusion, but it seems unexpected from above. Which is your L4T release ?

hi julien1:
1)have you tried CUDA_BIN_PATH=/usr/local/cuda path set?
2)since nvcc showed 10.2, and the path you set is cuda-8.0. maybe you need reflash the OS to keep cuda version match what nvcc showed

Thanks, I’ll try that.

I just reformatted my SD card and reflashed it cleanly to reset everything.

i’ll update.