Closed Guuri11 closed 6 months ago
Bug: Unknown argument -j
error when building OpenCV with CUDA using make install_cuda
Description:
I encountered an issue while trying to install GoCV with CUDA support by running sudo make install_cuda
. During the build process, the command fails with the following error message:
CMake Error: Unknown argument -j
CMake Error: Run 'cmake --help' for all supported options.
make[1]: *** No targets specified and no makefile found. Stop.
...
make: *** No rule to make target 'install'. Stop.
After inspecting the Makefile
, I observed that the cmake
command within the build_cuda
target incorrectly uses the -j
argument, which is not a valid option for cmake
.
Here is the relevant excerpt from the Makefile
:
build_cuda:
cd $(TMP_DIR)opencv/opencv-$(OPENCV_VERSION)
mkdir build
cd build
rm -rf *
cmake -j $(shell nproc --all --ignore 1) -D CMAKE_BUILD_TYPE=RELEASE ...
$(MAKE) -j $(shell nproc --all --ignore 1)
$(MAKE) preinstall
cd -
Proposed Fix:
The -j $(shell nproc --all --ignore 1)
should be removed from the cmake
command. The correct way to handle parallel builds is to use the -j
option with make
(which is already done correctly in the Makefile
).
Here is the corrected version of the build_cuda
target:
build_cuda:
cd $(TMP_DIR)opencv/opencv-$(OPENCV_VERSION)
mkdir build
cd build
rm -rf *
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
-D OPENCV_EXTRA_MODULES_PATH=$(TMP_DIR)opencv/opencv_contrib-$(OPENCV_VERSION)/modules \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=ON \
-D BUILD_opencv_java=NO \
-D BUILD_opencv_python=NO \
-D BUILD_opencv_python2=NO \
-D BUILD_opencv_python3=NO \
-D WITH_JASPER=OFF \
-D WITH_TBB=ON \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DWITH_CUDA=ON \
-DENABLE_FAST_MATH=1 \
-DCUDA_FAST_MATH=1 \
-DWITH_CUBLAS=1 \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ \
-DBUILD_opencv_cudacodec=OFF \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=7.5 \
-D CUDA_GENERATION=Auto ..
$(MAKE) -j $(shell nproc --all --ignore 1)
$(MAKE) preinstall
cd -
So, I has two issues here, the first one was that the -j $(shell nproc --all --ignore 1) should be removed from the cmake command in the build_cuda step.
the second one, was that I had my cuda directory at /usr/local/cuda-12/, and the Makefile is pointing to /usr/local/cuda/. So I just changed the route and it compiled successfully
just checked the DNN Pose Detection example setting CUDA as default backend, it works way better now comparing to the CPU, so I'm going to close the issue myself as it is finally solved 🚀
Description
I installed CUDA & cDNN following the guides, and then tried the
make install_cuda
from the root of gocv. But it fails, I can complete themake install
and it shows this message:but with make install_cuda happens this:
Steps to Reproduce
Your Environment
Processor: 13th Intel Core i5-13500Hx16
Graphics: NVIDIA RTX4050 / Mesa Intel® Graphics (RPL-P)
Operating System and version: Ubuntu 22.04.4 x64
OpenCV version used:
How did you install OpenCV? following this tutorial: https://gist.github.com/raulqf/f42c718a658cddc16f9df07ecc627be7
GoCV version used: gocv version: 0.36.1
Go version: go version go1.22.0 linux/amd64
Did you run the
env.sh
orenv.cmd
script before trying togo run
orgo build
? No