java.lang.UnsatisfiedLinkError: Could not load the native library

Hello,

I’m new to JCUDA. I’m trying to configure the development enviroment but despite my efforts I’m getting this error when trying to run the toy example:

JCuda.cudaMalloc(pointer, 4);
System.out.println("Pointer: "+pointer);
JCuda.cudaFree(pointer);```

Can someone help me to figure out what is happening?



Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load the native library.
Error while loading native library “JCudaRuntime-windows-x86_64” with base name “JCudaRuntime”
Operating system name: Windows 7
Architecture : amd64
Architecture bit size: 64
Stack trace from the attempt to load the library as a resource:
java.lang.UnsatisfiedLinkError: C:\Users\Ricardo\AppData\Local\Temp\JCudaRuntime-windows-x86_649184899135937542293.dll: Can’t find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1083)
at jcuda.LibUtils.loadLibraryResource(LibUtils.java:171)
at jcuda.LibUtils.loadLibrary(LibUtils.java:83)
at jcuda.runtime.JCuda.initialize(JCuda.java:340)
at jcuda.runtime.JCuda.(JCuda.java:327)
at JCudaRuntimeTest.main(JCudaRuntimeTest.java:11)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: D:\Programming\JCuda-All-0.6.5-bin-windows-x86_64\JCudaRuntime-windows-x86_64.dll: Can’t find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at jcuda.LibUtils.loadLibrary(LibUtils.java:94)
at jcuda.runtime.JCuda.initialize(JCuda.java:340)
at jcuda.runtime.JCuda.(JCuda.java:327)
at JCudaRuntimeTest.main(JCudaRuntimeTest.java:11)

at jcuda.LibUtils.loadLibrary(LibUtils.java:126)
at jcuda.runtime.JCuda.initialize(JCuda.java:340)
at jcuda.runtime.JCuda.<clinit>(JCuda.java:327)
at JCudaRuntimeTest.main(JCudaRuntimeTest.java:11)

Hello

The “UnsatisfiedLinkError” is covered in the FAQ at http://forum.byte-welt.net/byte-welt-projekte-projects/swogl-jcuda-jocl/jcuda/2972-jcuda-faq-please-read-posting.html . The message “Can’t find dependent libraries” usually indicates that it can’t find the actual CUDA DLLs. Have you installed CUDA from https://developer.nvidia.com/cuda-downloads (it should be a file called “cuda_6.5.14_windows_general_64.exe”)? This is the CUDA version that the latest JCuda version was built for.

bye
Marco

Unfortunately, I already knew about that post and after following every instructions the error keeps happening. So, if you have something useful I would appreciate.

Hello,

So far I installed the CUDA toolkit 6.5 and I’m using the 0.6.5 JCUDA version. I have a GFORCE GT 325M with the drivers installed.

I got this error in the first place:

java.lang.NullPointerException: No resource found with name '/lib/JCudaRuntime-windows-x86_64.dll'
	at jcuda.LibUtils.loadLibraryResource(LibUtils.java:149)
	at jcuda.LibUtils.loadLibrary(LibUtils.java:83)
	at jcuda.runtime.JCuda.initialize(JCuda.java:340)
	at jcuda.runtime.JCuda.<clinit>(JCuda.java:327)
	at JCUDAHello.main(JCUDAHello.java:10)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\JCudaRuntime-windows-x86_64.dll: Can't find dependent libraries
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1119)
	at jcuda.LibUtils.loadLibrary(LibUtils.java:94)
	at jcuda.runtime.JCuda.initialize(JCuda.java:340)
	at jcuda.runtime.JCuda.<clinit>(JCuda.java:327)
	at JCUDAHello.main(JCUDAHello.java:10)

	at jcuda.LibUtils.loadLibrary(LibUtils.java:126)
	at jcuda.runtime.JCuda.initialize(JCuda.java:340)
	at jcuda.runtime.JCuda.<clinit>(JCuda.java:327)
	at JCUDAHello.main(JCUDAHello.java:10)

My project have the folders src and bin. It seems that it expects dll files in the project folder /bin/lib/. Then, I put the DLL files in a lib folder project/bin/lib/ and then i got the error that originally a place here. Can you help me? I cannot see what i’m doing wrong…

Hello

I just had another look at the
dumpbin /DEPENDENTS JCudaDriver-windows-x86_64.dll
result, and it lists these dependencies:


  Image has the following dependencies:

    nvcuda.dll
    MSVCP110.dll
    MSVCR110.dll
    KERNEL32.dll

The MSVC DLLs are part of the MS Visual Studio Redistributable Package. I’m not entirely sure about the version that is needed here, but think it should be the one that is available at Download Visual C++ Redistributable for Visual Studio 2012 Update 4 from Official Microsoft Download Center

In any case, the JCuda DLL should actually not have this dependency, and I wonder how this slipped in. I’ll have to re-check the compiler settings of the VS files that are emitted by CMake, I guess one has to manually select some “Don’t link against some cr*ppy MS DLLs”-flag there :rolleyes:

Sorry for the inconveniences. If it still does not work, I’ll try to provide a version without these dependencies ASAP, but first have to figure out and test how they can be omitted.

Marco

OK, a small update here: I checked this again, and indeed, CMake generated Visual Studio Project files where some compiler flags caused a runtime dependency to some of the Microsoft Redistributables.

The Binaries (for Windows 32 and 64 bit) have been updated, so this dependency should no longer exist, and the CMake scripts have been extended to overwrite the respective flags, so that this will (hopefully) not happen again in future versions.

Sorry for the hassle. The updated binaries are available at jcuda.org - Downloads

That’s good, Marco:) Time to update mavenized jcuda as well :slight_smile:

P.S. I lost my sleep for last week try to find out what I did wrong that it’s working on Linux and not working on Windows

P.P.S. Marco, could you test updated version of my project?

It’s hard to “test” it in the sense that I never had this problem (because with Visual Studio, and with many other programs, the respective DLLs are installed by default), but I can try to run a test in the next days to verfiy that the DLLs that are used do no longer refer to the VS DLLs.

Umm… I seem to be experiencing the same problem as the Guy

Umm… I seem to be experiencing the same problem as the guy who started this thread, I have the same error code, the same normal code, the newest version (as of 12/2/2015) of JCuda and yes I have read and followed the FAQ thread on this and it didn’t help. Could someone help me? (sorry for forum error, I am new to this)

Hello,

I checked it again, and for example, the Win64 driver binaries do not contain any unwanted dependencies.

So you have CUDA 6.5 installed, together with the latest version of the JCuda binaries, on Win64?

bye

Everybody relax, I fixed it, I just needed to uninstall and reinstall my graphics driver, thanks for all the help :slight_smile:

Check that all DLL functions referred in your Java code are correctly defined and exported and export the same datatypes as those your Java code is expecting. This won’t stop the DLL loading, but it may well mess up the next stage - resolving link addresses or making functions that should work, fail in unexpected ways. Place the DLL in the current directory, in one of the directories listed in the PATH environment variable, or, best of all, in the native library search path, set using the system property java.library.path:

java -Djava.library.path=C:\MyNativeLibs MyMainClass

Thanks @antoniosarco - this is basically the information that is detailed in the JCuda FAQ . Fortunately, this now is mainly relevant for those who manually download the DLLs and JARs to set everything up locally. Starting with JCuda 0.8.0, the native libraries are contained in JAR (Maven Artifacts) and loaded from there. Since then, the number of bug reports related to UnsatisfiedLinkError have greatly decreased :slight_smile: