Unable to use JCublas2

cat /etc/ld.so.conf.d/nvidia.conf


I’ve used ldconfig as well as LD_LIBRARY_PATH.

No matter how I set it up the system can’t find the libraries.

It blows up on setting exceptions. Jcublas and everything else works fine.

Not sure what’s going on here.

The native bindings I"m using can be found here:

Any hints on how to troubleshoot this would be amazing.

Just to get this right: You can use all the libraries (including JCublas), but not JCublas2? Not even the sample from the samples page jcuda.org - Samples ? What do you mean when you say it “blows up on setting exceptions”? (I can’t imagine you mean the “setExceptionsEnabled” method, do you?)

Sorry let me clarify.

I mean when I call something as simple as:

Here is a minimal example:

If you use any jcublas operations on this you will notice it works fine.
I’m also able to successfully load the library with the static initializer.
I’m assuming I’m loading something wrong. It’s pretty opaque as of the moment though.


I contacted the contributor who provided the Linux64 binaries, maybe he has an idea. But you did not yet mention in which way it does not work. If calling JCublas2.etExceptionsEnabled(true); causes an UnsatisfiedLinkError, it could be helpful if you posted the complete stack trace.

Also, when you say that you are
…able to successfully load the library with the static initializer.
do you mean that calling JCublas2.initialize() does work?


*** Edit ***

I noticed a problem with the native binding of one of the JCublas2 methods. I’ll try to provide a fix for this ASAP (tomorrow).

Sorry for any inconveniences!

An updated version of JCuda has been uploaded: Version 0.7.0a. It contains a fixed version of the JCublas2 librarary, and you may grab it at jcuda.org - Downloads

Thanks to the contributor Adam Gibson, who compiled and tested the Linux binaries!

So your first round of tests passed. I can invoke jcublas2 now.

Next round of problems:
java.lang.UnsatisfiedLinkError: jcublas.JCublas2.cublasCreateNative(Ljcublas/cublasHandle;)I
at jcublas.JCublas2.cublasCreateNative(Native Method)
at jcublas.JCublas2.cublasCreate(JCublas2.java:136)
at org.nd4j.linalg.jcublas.context.ContextHolder.getHandle(ContextHolder.java:96)
at org.nd4j.linalg.jcublas.SimpleJCublas.gemv(SimpleJCublas.java:190)
at org.nd4j.linalg.jcublas.JCublasWrapper.gemv(JCublasWrapper.java:159)
at org.nd4j.linalg.api.ndarray.BaseNDArray.mmuli(BaseNDArray.java:2317)
at org.nd4j.linalg.api.ndarray.BaseNDArray.mmul(BaseNDArray.java:2138)
at org.nd4j.App$1.run(App.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Simply creating a handle:
Exception in thread “main” java.lang.UnsatisfiedLinkError: jcublas.JCublas2.cublasCreateNative(Ljcublas/cublasHandle;)I
at jcublas.JCublas2.cublasCreateNative(Native Method)
at jcublas.JCublas2.cublasCreate(JCublas2.java:136)
at org.nd4j.App.main(App.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

I apologize for speaking too soon. I assumed the problem was just a basic communication issue. I think we are back to square one.

I have updated the example:

All I do is create a handle and destroy it.

See the ‘EDIT’ below!

Does this also happen when you set up a basic test project as described in jcuda.org - Tutorial ?

  • Create a directory
  • Place all .SOs and .JARs in this directory
  • Create a file
import jcuda.jcublas.*;
public class JCublas2Test
    public static void main(String args[])
        cublasHandle handle =  new cublasHandle();
  • Compile it with javac -cp ".:jcuda-0.7.0a.jar" JCublas2Test.java
  • Run it with java -cp ".:jcuda-0.7.0a.jar" JCublas2Test

(Most likely, this will not work as well… I fear that there may be something wrong with the Build Scripts. But I don’t understand why this only happens for Linux, and only for JCublas2. Again: The other libraries (e.g. the basic Runtime Library, as tested with the “JCudaRuntimeTest” from the tutorial page) do work, is this correct?)

*** Edit ***

As mentioned in the mail: The part of the error message
java.lang.UnsatisfiedLinkError: jcublas.JCublas2.cublasCreateNative...
indicates that it grabs the wrong class. Namely, it loads
which is stored under the wrong package name. And the native methods are specific for the package name, so it can not find the appropriate method. The package name should be
and not only