Setting Library Paths in Eclipse on Linux

Hello;
I don’t know How to add the argument in Eclipse for the first type :Type 1: UnsatisfiedLinkError: Could not load native library

(Menu) “Run Configurations” -> (Tab) “Arguments” -> (Textbox) “VM Arguments” ==> what i must put in VM Arguments.

I use linux 64 bits.

THank you.

I’m new with jcuda. I try to write a simple example in eclipse on Linux. I have this error but I haven’t understand what it means. Here the code:

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

I add the Jcuda.jar from the java Build Path, and edit the Native library location by selecting the extracted jcuda file. The error is:

Error while loading native library "JCudaRuntime-linux-x86_64" with base name "JCudaRuntime" Operating system name: Linux Architecture : amd64 Architecture bit size: 64 Stack trace from the attempt to load the library as a resource: java.lang.NullPointerException: No resource found with name '/lib/libJCudaRuntime-linux-x86_64.so' at jcuda.LibUtils.loadLibraryResource(LibUtils.java:151) at jcuda.LibUtils.loadLibrary(LibUtils.java:83) at jcuda.runtime.JCuda.initialize(JCuda.java:303) at jcuda.runtime.JCuda.(JCuda.java:290) at cudaTest.main(cudaTest.java:8) Stack trace from the attempt to load the library as a file: java.lang.UnsatisfiedLinkError: /home/imen.heloulou/JCuda-All-0.4.2-bin-linux-x86_64/libJCudaRuntime-linux-x86_64.so: libcudart.so.4: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880) at java.lang.Runtime.loadLibrary0(Runtime.java:849) at java.lang.System.loadLibrary(System.java:1088) at jcuda.LibUtils.loadLibrary(LibUtils.java:94) at jcuda.runtime.JCuda.initialize(JCuda.java:303) at jcuda.runtime.JCuda.(JCuda.java:290) at cudaTest.main(cudaTest.java:8)

Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load the native library at jcuda.LibUtils.loadLibrary(LibUtils.java:129) at jcuda.runtime.JCuda.initialize(JCuda.java:303) at jcuda.runtime.JCuda.(JCuda.java:290) at cudaTest.main(cudaTest.java:8)

Could tou help me please, I’m really need the solution. Thank you in advance.

Hello

First of all: Have you installed the CUDA SDK from https://developer.nvidia.com/cuda-downloads , and do the version of CUDA (7.0) and of JCuda (0.7.0) match?

You may also want to run a basic test, as described in jcuda.org - Tutorial

However, when using Eclipse, your directory structure will be something like


YourWorkspace
    YourProject
        src
        bin

Then it should be sufficient to simply throw the whole contents of the JCuda ZIP package into your “YourProject” directory, and add the .JAR files to the classpath in Eclipse (the latter is what you probably have already done). Then it should not be necessary to add any VM parameters. (You can do this later, this is just a first test).

bye
Marco

Hello,

I have the same problem. In my machine the cuda was installed is: Cuda compilation tools, release 4.2, V0.2.1221. I have download: JCuda-All-0.4.2-bin-linux-x86_64.

Thank you in adavance.

OK, version 4.2 is reeeally old, but at least, the versions should match here.
Can you run a “Basic Test” as described in the tutorial? (That is: Does the problem only appear in Eclipse, or in general?)
And: Can you execute any of the CUDA samples? (Just to be sure that CUDA itself is installed properly)

I write this command: cuda-install-samples-4.2.sh /home/faith/JCuda-All-0.4.2-bin-linux-x86_64/; I have this error : cuda-install-samples-4.2.sh*: commande introuvable.

I’m not sure what this command does (I’m only using Windows), but … the installation of the CUDA samples should not be related to JCuda.
What happens when you just start
cuda-install-samples-4.2.sh
?

I changed the operating system, I work now with windows 7 64 bits. I have installed as you lod me the CUDA 7 SDK from https://developer.nvidia.com/cuda-downloads , and the JCuda (0.7.28). Now I have the error below, but I haven’t understand why it is mentionned that the Operating system name: Windows Vista
and Architecture bit size: 32, so I have window 7 64 bits.

Exception in thread „main“ java.lang.UnsatisfiedLinkError: Could not load the native library.
Error while loading native library „JCudaRuntime-windows-x86“ with base name „JCudaRuntime“
Operating system name: Windows Vista
Architecture : x86
Architecture bit size: 32
Stack trace from the attempt to load the library as a resource:
java.lang.NullPointerException: No resource found with name ‚/lib/JCudaRuntime-windows-x86.dll‘
at jcuda.LibUtils.loadLibraryResource(LibUtils.java:149)
at jcuda.LibUtils.loadLibrary(LibUtils.java:83)
at jcuda.runtime.JCuda.initialize(JCuda.java:375)
at jcuda.runtime.JCuda.(JCuda.java:362)
at test.JCudaRuntimeTest.main(JCudaRuntimeTest.java:10)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: no JCudaRuntime-windows-x86 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:94)
at jcuda.runtime.JCuda.initialize(JCuda.java:375)
at jcuda.runtime.JCuda.(JCuda.java:362)
at test.JCudaRuntimeTest.main(JCudaRuntimeTest.java:10)

at jcuda.LibUtils.loadLibrary(LibUtils.java:126)
at jcuda.runtime.JCuda.initialize(JCuda.java:375)
at jcuda.runtime.JCuda.(JCuda.java:362)
at test.JCudaRuntimeTest.main(JCudaRuntimeTest.java:10)

When it says “Architecture bit size: 32” then you most likely started it with a 32 bit Java JRE. You should try the 64bit version. (The fact that it says “Vista” should not be relevant here, though…)

It’s work now, thank you.