-
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
Add initial OpenCV CUDA bindings #416
Conversation
Bindings for opencv2/cuda.hpp, opencv2/cudaimgproc.hpp, opencv2/cudafilters.hpp Update cppbuild.sh to use all available cores (was hardcoded to 4) Removes the generated opencv_core.Stream class, but that was generated from a forward declaration in the header file so it wasn't useful anyway
Looking good thanks! There are few things to fix before we can merge this though:
@Platform(value = {"linux-x86_64", "linux-arm64", "linux-ppc64le", "macosx-x86_64", "windows-x86_64"}, ...
|
I think |
I don't think that's it, all the other modules don't change. Anyway, I'll
look into that. Make the other changes and it'll be fine!
One other thing though, to reduce build times, we should disable modules we
don't use...
|
CUDA remains enabled for linux x86_64, linux arm64, linux ppc64le, mac os, windows x86_64
I'm not too happy about stuff like this: public native void detectMultiScale(@ByVal Mat image,
@ByVal Mat objects);
public native void detectMultiScale(@ByVal UMat image,
@ByVal UMat objects);
public native void detectMultiScale(@ByVal GpuMat image,
@ByVal GpuMat objects); that should really only accept public native void detectMultiScale(@ByVal GpuMat image,
@ByVal GpuMat objects); FWIW, this method is generated from this declaration in virtual void detectMultiScale(InputArray image,
OutputArray objects,
Stream& stream = Stream::Null()) = 0; But |
We can remove "Mat" and "UMat" from the redefinition, or do we need them somewhere? If it's just one place or two, we can use Info.javaText() for those. BTW, the build is failing, on Windows:
|
Ouch, it looks like OpenCV builds for all these archs by default:
Limiting that to say |
/cc @vb216 It looks like it's failing on AppVeyor because CUDA isn't installed when building OpenCV. |
That sounds good. I'll try tackling that later this week. |
Currently requires custom CUDA bindings from javaccp-presets (see bytedeco/javacpp-presets#416) Trying to use CUDA-accelerated operations without an nvidia GPU and running nvidia drivers will probably crash the app
This should speed up compilation of the CUDA modules by about 6x and cut down the size of the output jar by about 60% (vs all CUDA platorms being buit)
Thanks! Now the build finishes on time for Linux, but still not for Mac :/ @vb216 is looking into stages, yes. It won't work for Windows with AppVeyor though :( So, recent versions of CUDA have issues compiling older PTX versions? That's unfortunate... |
Looks like the mac build was cancelled because the log got too big from warnings about unused parameters and functions in the core and cudev modules (mostly from stubs as far as I can tell) And it's a problem with the PTX JIT. Caused that double free and probably a bunch of other issues I'm randomly getting when the cuda module gets loaded. Never had any issues with the build my machine uses natively ( |
@vb216 What do you think? Should we merge this? |
Yeah fine with me. Nearly got nexus AWS instance working which would let us
rejig the jobs to make up some time too
…On 16 May 2017 06:29, "Samuel Audet" ***@***.***> wrote:
@vb216 <https://github.com/vb216> What do you think? Should we merge this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#416 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMYRJwBEZW4iwOWMaEWFZZsD6D-H-maUks5r6TQ4gaJpZM4NRX2h>
.
|
I see why some modules like
We'll need to add those to the |
Not sure how I missed that, but when built with CUDA, it looks like all libraries become dependent on CUDA! Check the output of
We can't have that. How should we deal with this? |
@saudet From my understanding, most modules will compile with CUDA support if the flag is set. If OpenCV loads the CUDA library only when a CUDA function is called (ie not at startup), like how Java does it, then I think it's okay. But if not, I think there would have to be separate builds for CUDA and non-CUDA versions |
All the libraries link statically with CUDA, so users would have to install it. It's ok for something like Caffe where most users use a GPU anyway, but that's not the case with OpenCV. |
Has anyone decided how to proceed? A separate CUDA build or not? |
We'll need another build, yes. But to make releases, I'd like to be able to
use Travis CI and AppVeyor. Could you help with that?
|
I've added an "extensions" feature to JavaCPP to allow us to have more than one set of binaries per platform: bytedeco/javacpp@35463a6. We still need to modify the pom.xml files of the presets a bit, but it should work as follows:
Furthermore, we should be able to create Maven profiles in the parent pom.xml to override the list of modules to only list the submodules that support say "cuda", and another list for say "avx512", etc. At runtime, JavaCPP will look at the Thoughts? /cc @akdeoras |
That's probably the best solution since OpenCV will break if built with CUDA and is loaded on a system that doesn't have CUDA support. Side note, Travis has beta support for build stages now so it should be possible to make the mac builds not time out any more. https://docs.travis-ci.com/user/build-stages/ |
I seem to recall there was still an issue with using stages and that's why we're not using them, @vb216 ? Also, it's not available on AppVeyor... |
Yeah problem is that there's no means of sharing output between build stages, there's issues open with Travis and Appveyor on this as alot of people are keen on that functionality. Thinking of using S3 to upload build output to, making it available to dependencies and then splitting out the long opencv chain. |
a1fa858
to
22f9ebd
Compare
Thanks for the contribution @SamCarlberg! Let me know if you encounter any problems using those functions. |
Currently requires custom CUDA bindings from javaccp-presets (see bytedeco/javacpp-presets#416) Trying to use CUDA-accelerated operations without an nvidia GPU and running nvidia drivers will probably crash the app
Creates bindings for:
opencv2/core/cuda.hpp
opencv_cuda
opencv2/cudaimgproc.hpp
opencv_cudaimgproc
opencv2/cudafilters.hpp
opencv_cudafilters
Addresses (but doesn't solve) #364, bytedeco/javacv#481