Skip to content
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

How to replace deprecated "new Context(Device.TYPE_GPU)" #645

Open
Daniel-Alievsky opened this issue Dec 15, 2022 · 5 comments
Open

How to replace deprecated "new Context(Device.TYPE_GPU)" #645

Daniel-Alievsky opened this issue Dec 15, 2022 · 5 comments

Comments

@Daniel-Alievsky
Copy link

I used the constructor "new Context(int dtype)" to get information about installed GPU devices. However, in current version this constructor is deprecated. How can I replace this call in modern API?

@saudet
Copy link
Member

saudet commented Dec 15, 2022

You're talking about OpenCV, right? Context.create(String), Context.getDefault(), or Context.fromDevice() don't look deprecated, so I guess we should be using one of those. But the available sample suggests attachContext() is the recommended way of going about that:
https://github.com/opencv/opencv/blob/4.x/samples/opencl/opencl-opencv-interop.cpp#L641

@Daniel-Alievsky
Copy link
Author

Yes, OpenCV. Maybe you know, how can I replace my simplest call Context context = new Context(Device.TYPE_GPU) ?

For Context.create(String), which string should be here?

@saudet
Copy link
Member

saudet commented Dec 16, 2022

My guess is that we can loop over the devices returned by Context.getDefault().

@Daniel-Alievsky
Copy link
Author

Right, but I don't see a simple way to detect which devices support GPU. TYPE_GPU was a convenient flag. Is it deprecated at all?

@saudet
Copy link
Member

saudet commented Dec 19, 2022

That's just a flag. We can easily use the API from OpenCL to query devices:
https://github.com/opencv/opencv/blob/4.x/samples/android/tutorial-4-opencl/jni/CLprocessor.cpp#L113
The C++ API of OpenCL hasn't been mapped (yet), but the C API is available:
http://bytedeco.org/javacpp-presets/opencl/apidocs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants