JCublas 0.8.0 UnsatisfiedLinkError: Can't find dependent libraries

Hello everybody!

I have recently installed CUDA 9 toolkit and tried running some JCuda 0.8.0 code on my local Windows 10 x64 machine in Eclipse IDE. I have successfully run some sample code found on the internet.

Next thing that I wanted to try is running some JCublas code, but got exception:

Exception in thread “main” java.lang.UnsatisfiedLinkError: Error while loading native library “JCublas2-0.8.0-windows-x86_64”
Operating system name: Windows 10
Architecture : amd64
Architecture bit size: 64
—(start of nested stack traces)—

Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JCublas2-0.8.0-windows-x86_64 in java.library.path
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.lang.System.loadLibrary(Unknown Source)
	at jcuda.LibUtils.loadLibrary(LibUtils.java:143)
	at jcuda.jcublas.JCublas2.initialize(JCublas2.java:81)
	at jcuda.jcublas.JCublas2.<clinit>(JCublas2.java:66)
	at jcublas.Main.sgemmJCublas(Main.java:70)
	at jcublas.Main.testSgemm(Main.java:54)
	at jcublas.Main.main(Main.java:30)
Stack trace from the attempt to load the library as a resource:
java.lang.UnsatisfiedLinkError: C:\Users\Xeobo\AppData\Local\Temp\JCublas-0.8.0-windows-x86_64.dll: Cant find dependent libraries
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(Unknown Source)
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.load0(Unknown Source)
	at java.lang.System.load(Unknown Source)
	at jcuda.LibUtils.loadLibraryResource(LibUtils.java:260)
	at jcuda.LibUtils.loadLibrary(LibUtils.java:158)
	at jcuda.jcublas.JCublas2.initialize(JCublas2.java:81)
	at jcuda.jcublas.JCublas2.<clinit>(JCublas2.java:66)
	at jcublas.Main.sgemmJCublas(Main.java:70)
	at jcublas.Main.testSgemm(Main.java:54)
	at jcublas.Main.main(Main.java:30)

---(end of nested stack traces)---
	at jcuda.LibUtils.loadLibrary(LibUtils.java:193)
	at jcuda.jcublas.JCublas2.initialize(JCublas2.java:81)
	at jcuda.jcublas.JCublas2.<clinit>(JCublas2.java:66)
	at jcublas.Main.sgemmJCublas(Main.java:70)
	at jcublas.Main.testSgemm(Main.java:54)
	at jcublas.Main.main(Main.java:30)

Since Eclipse successfully found JCublas-0.8.0-windows-x86_64.dll library, I suppose the problem is that I don’t have some other libraries that JCublas is dependent on. I think that only other library it should be dependent on is JCuda, so I tried to preloading it with System.loadLibrary but got the same error.

Kind Regards,
Vladimir Zbiljic

Right, the part of the stack trace that says “Cant find dependent libraries” indicates that it cannot find one of the libraries that JCublas-0.8.0-windows-x86_64.dll depends on. But the native JCublas library does not depend on the native JCuda library. The dependency from JCublas to JCuda only refers to the Java world - that is, to the JARs, but not to the natives. So manual preloading should not be necessary.

The library that is missing there is actually the native CUBLAS library.


Side note: If you have Visual Studio installed, you can actually look them up, with

dumpbin /DEPENDENTS JCublas-0.8.0-windows-x86_64.dll

which shows

Image has the following dependencies:

  cublas64_80.dll
  KERNEL32.dll

Depending on how you installed the CUDA 9 toolkit, the version 8 should still be available, and the required cublas64_80.dll could be located in

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\cublas64_80.dll

There are some options for making this “visible” to Java:

  • You could add the directory to your PATH environment variable (although this might cause some confusion, because your PATH now likely contains the corresponding directory of the CUDA 9 toolkit)
  • You could just copy the CUBLAS DLL into your project root. (This is somewhat ““pragmatic”” - it’s 39MB…)
  • You could start with -Djava.library.path=/path/to/DLL, which should allow Java to find the right DLL

In any case, the update of JCuda for CUDA 9 is on its way (although I’m a bit short on time right now)

1 „Gefällt mir“

Hi Marco!

It worked! Thank’s a lot for a quick response on this!

I was able to install cublas 8 on my local machine. Then I just have loaded cublas64_80.dll like:

static  
{
    System.load("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\bin\\cublas64_80.dll");  
}

Thanks again for the fast and detailed response!

Again: It should not be necessary to manually load DLLs. And particularly not in a platform-dependent way, with a path that only works on your (Windows) PC.

The options that I mentioned are supposed to be a bit more maintainable.

(But of course, this is up to you - if you do this only for a quick test, or as a temporary solution until JCuda for CUDA 9 is available, it might be OK…)