bytedeco/javacv

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

开放

#2,331 创建于 2025年3月31日

 (4 条评论) (0 个反应) (0 位负责人)Java (1,583 个派生)batch import
help wantedquestion

仓库指标

星标
 (6,985 个星标)
PR 合并指标
 (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?

贡献者指南