Can not solve UnsatisfiedLinkError

Hey,

I 've got a problem with the UnsatisfiedLinkError when running on Windows 7 (64bit). I read the sticky post and tried all the proposed solutions, but none of them worked. I keep getting the following error, when running the JCudaRuntimeSample:

Error while loading native library with base name "JCudaRuntime"
Operating system name: Windows 7
Architecture         : amd64
Architecture bit size: 64
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load native library
	at jcuda.LibUtils.loadLibrary(LibUtils.java:79)
	at jcuda.runtime.JCuda.assertInit(JCuda.java:225)
	at jcuda.runtime.JCuda.cudaMalloc(JCuda.java:1513)
	at JCudaRuntimeSample.main(JCudaRuntimeSample.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)

My setup is the following:
[ul]
[li] Set the -Djava.library.path VM parameter to point to the native lib directory
[/li][li] Installed Cuda Toolkit 3.1 (build 9)
[/li][li] Used the latest jcuda 64 bit binaries for windows from the jcuda website
[/li][/ul]

When I still got the error, I checked the dependencies of the jcuda runtime dll. This indicated a dependency on cudart64_31_9.dll. I then checked my cuda toolkit installation, which did indeed have this dll. I also checked whether this dll was in my path system variable, and this was also the case.

I don’t know what more I can do to fix this error. Any ideas?

Thanks in advance!

Hello

If I had another idea, I should probably have added it to the sticky thread already :wink:

According to the stack trace, you have started it from IntelliJ, which seems to invoke the main method through reflection… Maybe this causes problems? I’m not sure. But you may try the following:

Copy all native JCuda DLLs and JAR files into one directory, and add the following file as „JCudaRuntimeTest.java“ in the same directory:

import jcuda.*;
import jcuda.runtime.*;
public class JCudaRuntimeTest
{
    public static void main(String args[])
    {
        Pointer pointer = new Pointer();
        JCuda.cudaMalloc(pointer, 4);
        System.out.println("Pointer: "+pointer);
        JCuda.cudaFree(pointer);
    }
}

Then compile the program manually from the Command Line:


**C:\Test\>****javac -cp ".;jcuda-0.3.1.jar" JCudaRuntimeTest.java**

This should create the „JCudaRuntimeTest.class“ file. Then start the program with the following command:


**C:\Test\>****java -cp ".;jcuda-0.3.1.jar" JCudaRuntimeTest**

This should print some information about the pointer which was created in the program. (Note that in both cases no „-Djava.library.path“ should be necessary, because all the DLLs are in the same directory)

If this works, we can try to figure out how to get it running with IntelliJ.

If this does not work, we can try to figure out what’s wrong with the setup.

bye
Marco

Hey Marco,

I solved the issue, seems it was related to the JDK I used. For some obscure reason, it started working when I installed the 1.6-update21 JDK (64bit) as opposed to the 1.6-update18 (64bit) version.

Thanks for the help!

[QUOTE=SenjuDahr]Hey Marco,

I solved the issue, seems it was related to the JDK I used. For some obscure reason, it started working when I installed the 1.6-update21 JDK (64bit) as opposed to the 1.6-update18 (64bit) version.

Thanks for the help![/QUOTE]

I have JDK 1.6-update21(64 bit),
Windows7 64 bit, and I still have problems with “Can not solve UnsatisfiedLinkError”.
I tried all the things, listed in FAQ, but w\o result at all.

P.S.
I use Eclipse Helios.


Error while loading native library with base name "JCudaRuntime"
Operating system name: Windows 7
Architecture         : amd64
Architecture bit size: 64
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load native library
    at jcuda.LibUtils.loadLibrary(LibUtils.java:79)
    at jcuda.runtime.JCuda.assertInit(JCuda.java:225)
    at jcuda.runtime.JCuda.cudaMalloc(JCuda.java:1513)
    at test.main(test.java:15)

Hello

Please make sure that you installed the CUDA driver and the CUDA Toolkit version 3.1 from the NVIDIA CUDA download site. There should be a directory “C:\CUDA\bin” which should contain, for example, the cudart31_9.dll.

You might also want to test whether CUDA is working in general, by running one of the CUDA samples from NVIDIA, for example, the vector addition sample.

bye
Marco

Thx for your advice, ofcource I’ve installed Cuda SDK, both 32 and 64 bit versions.

I tried to run example from Nvidia site, but I haven’t understood the results.
It seems very strange for me.
I haven’t found any positive or negative results of programm work. Except word ‚passed‘ that gave me some hope :slight_smile:


C:\>"f:\vectorAdd\NVIDIA GPU Computing SDK\C\bin\win64\Release\vectorAddDrv.exe"

Vector Addition (Driver API)
> findModulePath found file at <f:\vectorAdd\NVIDIA GPU Computing SDK\C\bin\win6
4\Release\../../../src/vectorAddDrv/data/vectorAdd.ptx>
> initCUDA loading module: <f:\vectorAdd\NVIDIA GPU Computing SDK\C\bin\win64\Re
lease\../../../src/vectorAddDrv/data/vectorAdd.ptx>
> PTX JIT log:
: Considering profile 'compute_20' for gpu='sm_21' in 'cuModuleLoadDataEx_5'
PASSED

Press ENTER to exit...

p.s.
Sorry for bad English.

Hi

The good news is that „PASSED“ means that it worked properly. The bad news is that I’m running out of ideas what might be the reason for the UnsatisfiedLinkError. You mentioned that you installed the SDK in 32 and 64 bit - that’s a little bit unusual. First of all, the Driver and Toolkit should be installed only once. But since the „vectorAdd“ example worked, this seems to be no problem.
Can you please verify that your C:\CUDA\bin directory contains a file named „cudart31_9.dll“? I don’t really know what could be wrong there at the moment… :confused:

bye
Marco

I have cudart32_31_9.dll file in C:\Cuda\bin.
I had looked information about this file and finded out that cudart32_31_9.dll is 64 bit analog of 32 bit cudart31_9.dll.
It is said that Cuda toolkit v3.1 purposed for 32 bit architecture and v3.2 dedicated for 64 bit.

Oh sorry, my fault: The filname indeed is “cudart**32_31_9.dll" - but that’s the file for the 32 bit Toolkit. I think that on a 64 bit system, you should actually have the file "cudart64_**31_9.dll”.

The value printed in bold is the bit size - this may only be 32 or 64. The remainder of the filename is the CUDA version: 31_9 means “CUDA 3.1, build 9”.

You should probably install the 64 bit Toolkit form the CUDA download site. Please make sure that you als install the 64 bit driver (before installing the 64 bit toolkit).

It might(!) also work with the 32bit toolkit if you use a 32bit JVM and the 32bit version of the JCuda libraries. But I’m not sure if this is the appropriate solution for a 64bit system…

You may want to carefully check the dll dependencies on your environment.

I noticed for example that binaries from jcuda.org are built 7 and as such JCudaRuntime-windows-x86_64.dll coming with 0.3.2RC depends on cudart64_32_7.dll

However with the latest toolkit (as of now) from http://developer.nvidia.com/object/cuda_3_2_toolkit_rc.html cudart64_32_12.dll gets installed.

Hope this helps.

Yes, the most recent binaries are built for CUDA 3.2 RC, and a few days ago NVIDIA has published CUDA 3.2 RC2 … I’m not sure how many RC’s there are going to be, and I think they should really set up a timeline/roadmap… -_-
I’m not sure if I will build the binaries for the RC2 as well. But I’ll have to think about a strategy for that. Maybe I should add the target library version to the name of the native binaries as well, like "JCudaRuntime-windows-x86_64**_32_12**.dll - this might reduce the confusion a little bit… ?

I know this might sound like a hack but it’s the only thing that got rid of the exception for me. It was the .dll dependencies. The new 64_32_12.dll do not work with the rest of the newest installs. I made a copy of all of the dll’s that ended in 12 and made them end in 7. This made it work.

I hope this won’t mess anything else up. I will post back again if it does.

I think it might work (and thus, be feasible as a workaround) as long as the DLL function entry points did not change. In the worst case, it will not find some functions, which could lead to a crash of the JVM - it depends whether this would be really critical or just annoying… In doubt, it might be the most appropriate solution to compile the binares for the specific target platform and Toolkit version. Thanks to the CMake makefiles by Kashif Rasul, this should not be too difficult.
I hope that the final version of CUDA 3.2 will be out soon, then there will also be an update on the website.