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 use GPU? #1782

Closed
CJL6015 opened this issue Mar 21, 2022 · 27 comments
Closed

How to use GPU? #1782

CJL6015 opened this issue Mar 21, 2022 · 27 comments

Comments

@CJL6015
Copy link

CJL6015 commented Mar 21, 2022

I want to use gpu acceleration in ffmpeg and opencv mat. Is there any doucment or demo?

@saudet
Copy link
Member

saudet commented Mar 21, 2022

For FFmpeg, we can use codecs that support GPUs: https://trac.ffmpeg.org/wiki/HWAccelIntro

For OpenCV, use GpuMat and UMat, that's what works on GPU.

@CJL6015
Copy link
Author

CJL6015 commented Mar 21, 2022

I use the GpuMat, but n error occurred.
image

@CJL6015
Copy link
Author

CJL6015 commented Mar 21, 2022

This is my GPU
image

@saudet
Copy link
Member

saudet commented Mar 21, 2022

You'll need to use binaries for OpenCV compiled with CUDA, as shown in the README.md file here in the case of Maven:
https://github.com/bytedeco/javacpp-presets/tree/master/opencv#the-pomxml-build-file

@CJL6015
Copy link
Author

CJL6015 commented Mar 22, 2022

I add the dependecy of cuda-platform0redist. Do I need to da anything else?
image

@saudet
Copy link
Member

saudet commented Mar 22, 2022

You'll need to make sure the latest version of the drivers for your video card are installed on the system.

@CJL6015
Copy link
Author

CJL6015 commented Mar 22, 2022

I have updated the driver to the latest version, but it still doesn't work.
image

@saudet
Copy link
Member

saudet commented Mar 22, 2022

Set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more messages on the console.

@CJL6015
Copy link
Author

CJL6015 commented Mar 22, 2022

Is it so? It doesn't seem to work.
image

@saudet
Copy link
Member

saudet commented Mar 22, 2022

You'll need to set it earlier than that. Anyway, there's also issue #1767 that's been fixed recently, so make sure to give it a try with the snapshots: http://bytedeco.org/builds/

@CJL6015
Copy link
Author

CJL6015 commented Mar 22, 2022

I try with the snapshots,but got another error.
image

@saudet
Copy link
Member

saudet commented Mar 22, 2022

That means those functions don't work with GPUs. You'll need to find other (similar) functions that do support GPUs.

In this case, this one should do what you need: http://bytedeco.org/javacpp-presets/opencv/apidocs/org/bytedeco/opencv/global/opencv_cudaimgproc.html#cvtColor-org.bytedeco.opencv.opencv_core.GpuMat-org.bytedeco.opencv.opencv_core.GpuMat-int-int-org.bytedeco.opencv.opencv_core.Stream-

@saudet
Copy link
Member

saudet commented Mar 22, 2022

Duplicate of #1767

@saudet saudet marked this as a duplicate of #1767 Mar 22, 2022
@saudet saudet closed this as completed Mar 22, 2022
@CJL6015
Copy link
Author

CJL6015 commented Mar 22, 2022

I use the opencv_cudaimgproc.cvtColor,but got another error.
image

@saudet
Copy link
Member

saudet commented Mar 22, 2022

There's some library missing from your system, apparently. Please find out what it is using the Dependencies tool:
https://github.com/bytedeco/javacpp-presets/wiki/Debugging-UnsatisfiedLinkError-on-Windows

@CJL6015
Copy link
Author

CJL6015 commented Mar 23, 2022

I use the Dependencies tool,but opencv_cudaimproc and UMat/GpuMat can be loaded normally.Is it because I didn't set the correct module?
image

@saudet
Copy link
Member

saudet commented Mar 23, 2022

You'll need to give it the correct path to the DLL, if that's what you mean, yes. Look inside the JAR file to make sure you have it correctly.

@CJL6015
Copy link
Author

CJL6015 commented Mar 23, 2022

I mean opencv_cudaimgproc can be loaded normally without UnstatisfiedLinkError

@saudet
Copy link
Member

saudet commented Mar 23, 2022

So, everything should be working fine. I don't know what you tell you more.
For me on Windows 10, opencv_cudaimgproc.cvtColor() works perfectly.

@CJL6015
Copy link
Author

CJL6015 commented Mar 23, 2022

My system is Winows 11. Will this matter?

@saudet
Copy link
Member

saudet commented Mar 23, 2022

I don't think so, but you can try it on Windows 10 to see if it makes a difference.

@CJL6015
Copy link
Author

CJL6015 commented Mar 25, 2022

Could it be that the package I imported is wrong? I found a same question on stackoverflow:https://stackoverflow.com/questions/56944945/javacv-with-java-lang-unsatisfiedlinkerror.
Here are the packages I'm imported.
image

@saudet
Copy link
Member

saudet commented Mar 25, 2022

That doesn't matter. Make sure the "org.bytedeco.javacpp.logger.debug" system property is set to "true" to get possibly useful information displayed on the console.

@CJL6015
Copy link
Author

CJL6015 commented Mar 25, 2022

the "org.bytedeco.javacpp.logger.debug" system property is set to "true",but no more information.
image

@saudet
Copy link
Member

saudet commented Mar 25, 2022

It needs to be set earlier.

@CJL6015
Copy link
Author

CJL6015 commented Mar 25, 2022

These libraries failed to load.
`

Debug: Loading library zlibwapi
Debug: Failed to load for zlibwapi: java.lang.UnsatisfiedLinkError: no zlibwapi in java.library.path
Debug: Loading library cudart64_110
Debug: Failed to load for cudart64_110: java.lang.UnsatisfiedLinkError: no cudart64_110 in java.library.path
Debug: Loading library cublasLt64_11
Debug: Failed to load for cublasLt64_11: java.lang.UnsatisfiedLinkError: no cublasLt64_11 in java.library.path
Debug: Loading library cublas64_11
Debug: Failed to load for cublas64_11: java.lang.UnsatisfiedLinkError: no cublas64_11 in java.library.path
Debug: Loading library cufft64_10
Debug: Failed to load for cufft64_10: java.lang.UnsatisfiedLinkError: no cufft64_10 in java.library.path
Debug: Loading library cudnn64_8
Debug: Failed to load for cudnn64_8: java.lang.UnsatisfiedLinkError: no cudnn64_8 in java.library.path
Debug: Loading library nppc64_11
Debug: Failed to load for nppc64_11: java.lang.UnsatisfiedLinkError: no nppc64_11 in java.library.path
Debug: Loading library nppial64_11
Debug: Failed to load for nppial64_11: java.lang.UnsatisfiedLinkError: no nppial64_11 in java.library.path
Debug: Loading library nppicc64_11
Debug: Failed to load for nppicc64_11: java.lang.UnsatisfiedLinkError: no nppicc64_11 in java.library.path
Debug: Loading library nppicom64_11
Debug: Failed to load for nppicom64_11: java.lang.UnsatisfiedLinkError: no nppicom64_11 in java.library.path
Debug: Loading library nppidei64_11
Debug: Failed to load for nppidei64_11: java.lang.UnsatisfiedLinkError: no nppidei64_11 in java.library.path
Debug: Loading library nppif64_11
Debug: Failed to load for nppif64_11: java.lang.UnsatisfiedLinkError: no nppif64_11 in java.library.path
Debug: Loading library nppig64_11
Debug: Failed to load for nppig64_11: java.lang.UnsatisfiedLinkError: no nppig64_11 in java.library.path
Debug: Loading library nppim64_11
Debug: Failed to load for nppim64_11: java.lang.UnsatisfiedLinkError: no nppim64_11 in java.library.path
Debug: Loading library nppist64_11
Debug: Failed to load for nppist64_11: java.lang.UnsatisfiedLinkError: no nppist64_11 in java.library.path
Debug: Loading library nppisu64_11
Debug: Failed to load for nppisu64_11: java.lang.UnsatisfiedLinkError: no nppisu64_11 in java.library.path
Debug: Loading library nppitc64_11
Debug: Failed to load for nppitc64_11: java.lang.UnsatisfiedLinkError: no nppitc64_11 in java.library.path
Debug: Loading library npps64_11
Debug: Failed to load for npps64_11: java.lang.UnsatisfiedLinkError: no npps64_11 in java.library.path
Debug: Loading library cudnn_ops_infer64_8
Debug: Failed to load for cudnn_ops_infer64_8: java.lang.UnsatisfiedLinkError: no cudnn_ops_infer64_8 in java.library.path
Debug: Loading library cudnn_ops_train64_8
Debug: Failed to load for cudnn_ops_train64_8: java.lang.UnsatisfiedLinkError: no cudnn_ops_train64_8 in java.library.path
Debug: Loading library cudnn_adv_infer64_8
Debug: Failed to load for cudnn_adv_infer64_8: java.lang.UnsatisfiedLinkError: no cudnn_adv_infer64_8 in java.library.path
Debug: Loading library cudnn_adv_train64_8
Debug: Failed to load for cudnn_adv_train64_8: java.lang.UnsatisfiedLinkError: no cudnn_adv_train64_8 in java.library.path
Debug: Loading library cudnn_cnn_infer64_8
Debug: Failed to load for cudnn_cnn_infer64_8: java.lang.UnsatisfiedLinkError: no cudnn_cnn_infer64_8 in java.library.path
Debug: Loading library cudnn_cnn_train64_8
Debug: Failed to load for cudnn_cnn_train64_8: java.lang.UnsatisfiedLinkError: no cudnn_cnn_train64_8 in java.library.path
`

@saudet
Copy link
Member

saudet commented Mar 25, 2022 via email

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