-
Notifications
You must be signed in to change notification settings - Fork 747
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
GPU engine in DNNL disabled by default #938
Comments
No idea, OpenCV builds and runs fine with OpenCL enabled. Would you mind inquiring upstream? |
@saudet Thanks! I've opened the issue upstream. oneapi-src/oneDNN#823 |
It looks like DNNL doesn't link with |
Yes, I'll investigate this. If I understand correctly, that extension would give the user a choice to either use javacpp's dnnl default, or the one where both cpu and gpu are enabled (*-gpu extension)? That would be great, since both the "safe and stable" and "all features on" are available. |
Yes, that's correct, and it can fall back automatically on the CPU-only binary when the GPU one fails to load. BTW, it seems to support only Intel GPUs on Linux and Windows (Mac isn't supported), so I'm not sure if it's worth the trouble. |
If I understood correctly, based on the CPU use cases, the idea is not that these engines are exclusive, but that, similarly to OpenCL, you query the DNNL library for available engines, select the one you like (there can be even more than one CPU engine), and use it. So, the same binary should be able to load both CPU and GPU. But I might be wrong (but then the related DNNL API doesn't make much sense). As GPU part is disabled by the default build, the query for engines will only return the CPU engine. As for whether it's worth the effort, I thought that all underlying specifics are handled by DNNL, so from the user's point of view, including GPU in the build would enable more options, which shouldn't hurt. Most Intel's GPUs would not be competitive even with CPUs, but, on the other hand, Intel seems to be stepping up their game, so increasingly better options might be available soon. Anyway, this is not a priority, but would be nice to have at least for experimentation... |
Here's what the DNNL folks say:
In our case, can javacpp's DNNL ship with libopencl.so included? (I guess that would be it, but it's better to check before I try messing up with the build. In that case, do I have to configure that manually, or javacpp will figure it out and include it automatically?) |
The API doesn't look that easy to use to me. You're probably looking more for something like ONNX Runtime.
Sure, we probably just need to add the
Like I said, if we create an |
I already use DNNL and, though the API could be much more straightforward, I use it through my wrappers that simplify the use a lot, so I'm fine with it :)
Will do! |
This is just a note that I haven't forgotten this. I was just overwhelmed with other pressing work. I plan to do this within the next two weeks. |
I've enabled the OpenCL backend by default for Linux in the latest commit. Maybe we can reasonably assume that almost all users will have |
Hi @saudet Thank you! I have two newer computers, but neither of them has an integrated GPU, since they are a combination of powerful Inetl CPU and a recent Nvidia GPU. Related to the libOpenCL issue. Is this going to work as before if a user doesn't have libOpenCL? I've moved that file temporarily just to try this out, and it doesn't make any difference. The old code still works, and the library doesn't even try to load libOpenCL, although I've tried to list GPU engines in the appropriate DNNL api. In that regard, it seems that the latest changes might be optimal:
However, I haven't been able to test the 2nd point... |
OpenCL doesn't need to be present, but a library named |
Hmmm, I thought so, but then when I remove that libOpenCL.so, |
|
I was writing from the top of my head. This is the exact file I removed: |
... and both |
What does |
|
And if you remove |
clinfo: error while loading shared libraries: libOpenCL.so.1: cannot open shared object file: No such file or directory |
At the same time, my code using javacpp dnnl platform "1.6.2-1.5.5-SNAPSHOT" is loading without problems. |
I mean, that's not a bug, that's a wonderful feature! We just have to make sure there's not something else at play here. Because I don't think that the majority of users have opencl installed.... |
Try again with 1.6.3-1.5.5-SNAPSHOT to make sure it's not using some old binaries from somewhere... |
Still working without libOpenCL.so.1. |
Nope, we need libOpenCL.so.1: https://groups.google.com/g/javacpp-project/c/3s29mosfyTI/m/3NimBckyAgAJ |
Hmmm. That seems quite logical. I'm puzzled how it works on my machine when I remove libOpenCL.so (and .1 etc.)... |
I've added presets for OpenCL, and made DNNL depend on them, so it can use the OpenCL libraries from them. They don't need to be installed on the system anymore. OpenCL is now enabled for both Linux and Windows builds. Let me know if you're having any issues with that though! Thanks |
Thanks! I'll check it out. Additionally, it might be a good opportunity to try to support the new OpenCL bindings in my libraries. I see that you support OpenCL 3.0. Are they compatible with existing OpenCL 2.0? I remember that when they announced OpenCL 3.0 they mentioned that it's based on 1.2, but 2.0 is supported for existing implementations, but I was confused what that actually meant... |
Right, OpenCL 3.0 is basically OpenCL 1.2 with everything from 2.0 as optional extensions. That way, they are making NVIDIA GPUs compliant with the latest version of OpenCL :) |
Thanks. I meant: would I be able to port existing OpenCL 2.0 code to bytedeco's OpenCL 3.0? Are the functions that I'd expect in OpenCL 2.0 available somewhere in bytedeco's bindings? (I'm not sure what being an extension means regarding a Java JNI binding). |
Everything from OpenCL 2.x is available, yes, it will just error out if you try to call those functions on a GPU from NVIDIA: |
That's great news. I'll definitely check this out and see how to integrate it in my libraries. Will cry for help if I stumble on a problem, I hope you wouldn't mind :) |
OpenCL-enabled builds of DNNL 2.1.1 have now been released with version 1.5.5. Enjoy! |
@saudet It seems that system-wide OpenCL 3.0 is needed, but only if Nvidia's cuDNN is loaded. I'm currently using JCuda's cuDNN, so I'm not sure whether this would appear if I used JavaCPP's cuDNN, but the exception is raised by JavaCPP, which I use via DNNL. Please see this issue (I solved that on my machine by installing Intel's OpenCL and generic OpenCL 3.0 loader alongside the OpenCL that comes with CUDA). |
Personally, this is not an issue to me, since I solved it by system wide OpenCL 3.0, but some users who use DNNL/CUDA might be hit by a similar discrepancy issue. |
NVIDIA doesn't support using multiple versions of CUDA like that in the same application. You should use only a single version of CUDA in any given application. If you wish to use libraries from the JavaCPP Presets built with a different version of CUDA than is supported by JCuda, it's going to cause issues like that. |
Hmmmm, I'm not sure I follow. I don't use any JavaCPP CUDA (10.2 or other). I use JavaCPP DNNL stable 1.5.5 (which, as I understand, pulls some JavaCPP OpenCL dependency), and JCuda's CUDA 10.2. Both JCuda and JavaCPP CUDA (stable) link to CUDA 10.2, but is that relevant at all, since I don't pull JavaCPP CUDA dependency at all? |
JCuda or something is obviously loading an old version of OpenCL. That's not going to work. |
It looks like you're loading JOCL that doesn't support OpenCL 3.0 in here: |
Could be that, but, curiously, everything works well if the system-wide platform is up-to date (in my case, installing ocl-icd and Intel's OpenCL; I'm not sure which of these two solved it). |
Possibly, yes, but like I said, it's never a good idea to try to run multiple versions of the same library in the same application, whether it be Java, CUDA, OpenCL, etc. Don't do that! |
You are right about that! I just can't pinpoint the point where the collision happens, since in this case no OpenCL should be loaded at all, since:
|
You can set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information at load time. |
Thanks! |
Hi! I turned on debugging and this is the output I got:
|
@qeshi Your cuda path (/usr/local/cuda-11.3/lib64) suggests that you have CUDA 11.3, whereas JCuda (and JavaCPP 1.5.5 CUDA too) has been built with CUDA 11.2. Please make sure that CUDA 11.2 is installed, instead of 11.3. |
Ok! Now I get this exception.
I solved this before by adding Should I just install I tried to use [org.bytedeco/mkl-platform-redist "2020.3-1.5.4"] in the deep-diamond project, and got the following exceptions.
|
@qeshi Please follow https://neanderthal.uncomplicate.org/articles/getting_started.html |
sorry! |
@qeshi There's something in your application that is incorrectly loading /usr/local/cuda-11.2/lib64/libOpenCL.so and it's not JavaCPP, so you'll need to figure out where that gets loaded, and fix that. |
javacpp ships DNNL with the GPU engine disabled. This is the default build in upstream DNNL:
What is required to enable it in javacpp (by default)? Does the absence of javacpp preset for OpenCL block it, or it it not required, but you simply chose to follow the DNNL default?
The text was updated successfully, but these errors were encountered: