JCuda Vector Addition not working

Hello everyone. I am trying really hard to setup jcuda so that i can run basic samples. I have cuda running properly on version 11. However my jcuda doesnt work when i run a vector addition sample. I get this error:
java: package com.jogamp.opengl does not exist

Conceptually, when you download a specific version of jcuda, you need specific dependencies in the pom file, right? Additionally, you need a specific cuda version, correct? then i add the cuda to the classpath of the jcuda project? i cant tell if i am missing anything conceptually.

I am using the jcuda-master from github, which contains samples like:
JCudaVectorAdd

Also i downloaded these JAR’s from the jcuda tutorial:
The JAR files for JCuda and JCudnn, version 10.0.0

Please let me know if i am missing anything

The vector addition sample should not use com.jogamp.opengl at all. I assume that you just cloned https://github.com/jcuda/jcuda-samples . Note that there is a disclaimer in the README, that says that additional libraries may be required, but at least Jogamp is part of the POM, so this should not be the reason.

Are you actually using a Maven project/build?

Also note that your JCuda version and your CUDA version have to match. So when you have CUDA 11.0 installed, you have to use JCuda 11.0.0.


Depending on your goal and your current state, there are different paths forward.


Edit:

I’d recommend the second approach. Either use jcuda-example-maven as a basis, or set up a new, empty Maven project where you only add the JCuda dependencies to the POM, and only add https://github.com/jcuda/jcuda-samples/blob/master/JCudaSamples/src/main/java/jcuda/nvrtc/samples/JNvrtcVectorAdd.java (in contrast to the other vector additon sample, this one does the compilation on the fly, which may be easier for a first test).


If everything fails, you can also try to use JavaCPP instead of JCuda: https://github.com/bytedeco/javacpp-presets/tree/master/cuda#sample-usage

Just to add some insights from last night on discord. His Java experience level is beginner, he is using IntelliJ as an IDE and he downloaded and included the JARs manually in the classpath, including JOGL after this post was made. (I hope it works now.)

Again, JOGL should not be necessary for the Vector Addition example (it would only be necessary for the OpenGL-interop-examples).

It indeed complains about a missing package here, and I vaguely remember that it was not always obvious to pick the right JARs for JOGL… :-/ So if the goal is to add JOGL, we can sort that out dedicatedly.

Not after your post, after his post - last night. I advised him that there is probably no need for the OpenGL library for his use-case as well, even though I have no experience with your library. I am just saying that we got JOGL downloaded and added to the classpath either way. Your post was made a few hours after that. :wink: