Giter Club home page Giter Club logo

Comments (3)

Guuri11 avatar Guuri11 commented on September 26, 2024

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 -

from gocv.

Guuri11 avatar Guuri11 commented on September 26, 2024

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

from gocv.

Guuri11 avatar Guuri11 commented on September 26, 2024

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 🚀

from gocv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.