My first jcuda program

Please help me to find out the solution to this probem.

bibrak@bibrak-laptop:/media/Academics/Academic/Research/HPC/CUDA/JCUDA$ javac -cp .:$JCUDA_HOME/jcuda-0.2.3.jar:$JCUDA_HOME/jcublas-0.2.3.jar:$JCUDA_HOME/jcufft-0.2.3.jar:$JCUDA_HOME/jcudpp-0.2.3.jar JCudaRuntimeSample.java

COMPILES OK

And when I run it, it runs and gets errorr …

bibrak@bibrak-laptop:/media/Academics/Academic/Research/HPC/CUDA/JCUDA$ java -cp .:$JCUDA_HOME/jcuda-0.2.3.jar:$JCUDA_HOME/jcublas-0.2.3.jar:$JCUDA_HOME/jcufft-0.2.3.jar:$JCUDA_HOME/jcudpp-0.2.3.jar JCudaRuntimeSample
Creating input data
Initializing device data using JCuda
Error while loading native library with base name “JCudaRuntime”
Operating system name: Linux
Architecture : i386
Architecture bit size: 32
Stack trace:
java.lang.UnsatisfiedLinkError: no JCudaRuntime-linux-x86 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at jcuda.LibUtils.loadLibrary(LibUtils.java:53)
at jcuda.runtime.JCuda.assertInit(JCuda.java:227)
at jcuda.runtime.JCuda.cudaMalloc(JCuda.java:844)
at JCudaRuntimeSample.main(JCudaRuntimeSample.java:47)

Hello

I’m not a linux expert, but as far as I know you have to add the path which contains the native library to your LD_LIBRARY_PATH environment variable. According to the CUDA release notes you probably have to add the following lines to the file ~/.bash_profile from your home directory:


LD_LIBRARY_PATH=$LD_LIBRARY_PATH:**thePathContainingTheJCudaLibraries**
export LD_LIBRARY_PATH

You may also want to look into the release notes at http://developer.download.nvidia.com/compute/cuda/2_3/sdk/docs/cudasdk_release_notes_linux.txt, where this is described for the CUDA libraries (search for "LD_LIBRARY_PATH in this document). I assume that the same has to be done for the path which contains the native JCuda libraries, so that they may be loaded dynamically from Java.

bye
Marco13

Great it works :slight_smile:

Great to hear that :slight_smile:

Alternatively, I think it should also work to add the libraries to the java.library.path, either via the command line or in your IDE.

I have also put this solution in the NVIDIA CUDA forums General CUDA GPU Computing Discussion