bytedeco/javacv

Constructor for GpuMat class fails with RuntimeException due to no CUDA support detected

Open

#2,331 建立於 2025年3月31日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)Java (1,583 fork)batch import
help wantedquestion

倉庫指標

Star
 (6,985 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

I'm running Ubuntu Linux 24.10 with Java 21 installed. I have a copy of opencv 4.10 that I built from source with CUDA enabled in /opt/opencv and javacv 1.5.11 installed.

If I call new GpuMat() in my application I get the exception

Exception in thread "Worker Thread" java.lang.RuntimeException: OpenCV(4.10.0) /home/runner/work/javacpp-presets/javacpp-presets/opencv/cppbuild/linux-x86_64/opencv-4.10.0/modules/core/include/opencv2/core/private.cuda.hpp:106: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'

	at org.bytedeco.opencv/org.bytedeco.opencv.opencv_core.GpuMat.allocate(Native Method)
	at org.bytedeco.opencv/org.bytedeco.opencv.opencv_core.GpuMat.<init>(GpuMat.java:93)
	at jgauss/jgauss.worker.OpenImageRequest.processRequest(OpenImageRequest.java:35)
	at jgauss/jgauss.worker.BGThread.run(BGThread.java:53)

I enabled -Dorg.bytedeco.javacpp.logger.debug=true to see if anything failed to load, and the only remaining failure i have is for nppicom which appears to no longer exist with current CUDA if I have /opt/opencv/lib included first in LD_LIBRARY_PATH. If I remove /opt/opencv/lib from LD_LIBRARY_PATH then I also get an error telling me that opencv_cudev is not in java.library.path so LD_LIBRARY_PATH seems to be honored.

I compiled the following program to see if my opencv libraries supported CUDA, ran it, and saw the memory was allocated on the GPU by watching nvidia-smi

#include <opencv2/core/cuda.hpp>
#include <unistd.h>

int main(int argc, char *argv[]) {
    cv::cuda::GpuMat *mat = new cv::cuda::GpuMat(10000, 10000, CV_MAKETYPE(CV_32F, CV_32FC4));
    sleep(60);
}

So I'm not sure what's going wrong with the java code. I'm running this in a current Eclipse IDE, where there are no error message other than this when I run it, so I think my Eclipse run environment is set up correctly.

Suggestions?

貢獻者指南