-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance problem with UMat #488
Comments
We would probably need to enable OpenCL to let is use the GPU. It is indeed something that is possible with the new "extensions" feature, see #416, for example, but someone needs to take the time and make it happen. |
Sorry, I didn't understand well how can I use this feature. Should I add anything to my pom file? Currently I have
(or something similar for 3.3.1). What must I change? |
Like I said, someone needs to work on that before we can use it... |
Ok, thank you. I'll appreciate if you will tell me here when this issue will be resolved. |
I've merged support for OpenCL with commit 681ca06 . |
I've re-checked the speed with the current snapshot |
We're having issues with Travis CI. You'll need to build them locally if
you want to have them right away.
|
It is not so urgent, but I'm interested in stable solution, which will work from Java with maven Javacpp modules. Can I hope that this will be resolved soon? |
Probably "soon", but some help would make it "sooner" :)
|
Binaries are now available! You can test them with something like this in your <dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv-platform</artifactId>
<version>3.3.1-1.3.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>3.3.1-1.3.4-SNAPSHOT</version>
<classifier>linux-x86_64-gpu</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>3.3.1-1.3.4-SNAPSHOT</version>
<classifier>windows-x86_64-gpu</classifier>
</dependency> |
I've switched to this version in POM and rechecked my test from IntelliJ IDEA. Mat org.bytedeco.javacpp.opencv_core$Mat[width=1000,height=1000,depth=8,channels=3] (at 0xafde10) blurred by 91x91 in 108.459 ms What else should I do to enabled GPU support? |
You need to have OpenCL drivers installed for your card.
|
And we might also need to call |
I've reloaded maven library, but I cannot find Java methods called "haveOpenCL()" or "setUseOpenCL". Also, what are OpenCL drivers and how must I specify them while using JavaCPP opencv? I have native C++ software that successfully use opencv UMat with high performance. It works without any problems on my Windows 8.1. |
For comparison, we've created very simple C++ test:
It works fine, without any additional drivers, it requires only opencv_world331.dll reading file 'example.png' |
Usually no need to install anything special. It works fine here on Linux: public static void main(String[] args) {
System.out.println(haveOpenCL());
System.out.println(useOpenCL());
} outputs
|
Where can I find haveOpenCL() and useOpenCL() methods? In which package/class? |
Ok, after full reloading new maven libraries (3.3.1-1.3.4-SNAPSHOT, windows-x86_64-gpu) I see these methods. Unfortunately, both methods return false, The direct call "opencv_core.setUseOpenCL(true);" does not help. At the same time, C++ test works fine. What can I do now? It seems that IntelliJ IDEA cannot completely load something. But in C:\Users\Daniel.m2\repository\org\bytedeco\javacpp-presets\opencv\3.3.1-1.3.4-SNAPSHOT directory I see correct JAR opencv-3.3.1-1.3.4-SNAPSHOT-windows-x86_64.jar with full set of DLLs... |
That just means that the `-gpu` version of the artifact isn't in your class
path...
|
Now it works, thank you! :) |
Version 1.4 has been released with GPU-enabled binaries for OpenCV 3.4.0: |
I believe that UMat matrix processing should work essentially faster on a computer with GPU. I tested GaussianBlur function with 1000x1000 RGB image, kernel 91x91, and in C++ (Windows) the difference is impressive: Mat is processed in 100 ms, UMat in 6 ms. (On a computer of my colleague, UMat is processed even in ~1 ms, while Mat in the same time 100 ms.)
Javacpp OpenCV bridge supports UMat. But I don't see any difference in speed! (javacpp-presets, opencv, 3.3.1-1.3.4-SNAPSHOT) Why? Maybe the reason is too "conservative" build of OpenCV dlls inside Windows JAR opencv-3.3.1-1.3.4-20171206.015716-63-windows-x86_64.jar, where GPU and multikernel CPU optimization is disabled? If so, maybe, you can provide alternative builds (for example, with other "classifier" or other artifactId) where all possible optimization is enabled?
Below is my test:
`
public final class SimpleJavaCPPOpenCV {
private static final int KERNEL_SIZE = 91;
}
`
And its results of my computer for 1000x1000 RGB test image:
Mat org.bytedeco.javacpp.opencv_core$Mat[width=1000,height=1000,depth=8,channels=3] (at 0xb7f310) blurred by 91x91 in 102.501 ms
UMat org.bytedeco.javacpp.opencv_core$UMat[address=0xb8d040,position=0,limit=1,capacity=1,deallocator=org.bytedeco.javacpp.Pointer$NativeDeallocator[ownerAddress=0xb8d040,deallocatorAddress=0x7ff8604663e0]] (at 0xb8d040) blurred by 91x91 in 99.260 ms
Mat org.bytedeco.javacpp.opencv_core$Mat[width=1000,height=1000,depth=8,channels=1] (at 0xb7f310) blurred by 91x91 in 32.711 ms
UMat org.bytedeco.javacpp.opencv_core$UMat[address=0xb8d760,position=0,limit=1,capacity=1,deallocator=org.bytedeco.javacpp.Pointer$NativeDeallocator[ownerAddress=0xb8d760,deallocatorAddress=0x7ff8604663e0]] (at 0xb8d760) blurred by 91x91 in 32.568 ms
The text was updated successfully, but these errors were encountered: