UnsatisfiedLinkError JCudaRuntime, Permission denied, Linux


#1

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 JCudaRuntimeTest.main(JCudaRuntimeTest.java:8)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError: /lib/libJCudaRuntime-linux-x86_64.so: /lib/libJCudaRuntime-linux-x86_64.so: cannot open shared object file: Permission denied
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at jcuda.LibUtils.loadLibrary(LibUtils.java:94)
at jcuda.runtime.JCuda.initialize(JCuda.java:303)
at jcuda.runtime.JCuda.(JCuda.java:290)
at JCudaRuntimeTest.main(JCudaRuntimeTest.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 JCudaRuntimeTest.main(JCudaRuntimeTest.java:8)

I tried almost everything I can to deal with the problem. I can not manage it, so here ask for help. I can run the code correctly in cmd command, but when I went to eclipse, the errors comes out.


#2

the native library files have to be found by de JVM
http://www.jcuda.org/tutorial/TutorialIndex.html#GeneralSetup

The JAR files have to be present in the CLASSPATH, and [B]the native library files must be located in a path that is visible for Java[/B]. In most cases, this should either be a path that is given as a [B]java.library.path[/B] for the JVM, or the root directory of the project. (Alternatively, they can also be in a path that is contained in an environment variable like the PATH environment variable on Windows or the [B]LD_LIBRARY_PATH environment variable on Linux[/B]).

*** Edit ***

In Eclipse these libraries can be included via Build Path (right mouse click on project)


#3

"cannot open shared object file: Permission denied"
sounds like a problem of file permissions

can you test a normal program with File/ FileInputStream, read files in /lib ?

i do not know enough about linux/ file permissions there and maybe special rights for build path,
but think about under which user ecplise is running, what kind of file permissions need to be set

maybe better ask in a linux forum, maybe the same problem for any programm working with files (in such a special directory)


if file permissions arent manageable, then it should be a windows-system without any security configuation :wink:
(and no network!)
(edit: or a linux under user root?)

edit: copy the libraries to a user directory/ change buildpath?


#4

[MENTION=1562]_Michael[/MENTION]: In fact, there are two stack traces printed:

Stack trace from the attempt to load the library as a resource:

Stack trace from the attempt to load the library as a file:

The reason for this is that there are (in general) two options for handling the native libraries: One is to put them into the JAR file, and the other is to put them into a directory. Loading a native library from a JAR is a bit tricky, and this is currently not “officially supported” in JCuda. (It is used in JOCL, however, … things are a little bit simpler there…).

So the actual error message is, as SlaterB pointed out, the message “cannot open shared object file: Permission denied”. Interestingly, a websearch for “cannot open shared object file: Permission denied java” immediately leads to … THIS thread! However, without ‘java’, it brings some more results. I’m also not so familiar with possible permission caveats in Linux. Maybe http://ubuntuforums.org/showthread.php?t=1892577 or http://ubuntuforums.org/showthread.php?t=2150686 already bring some helpful hints…? In any case, it would be good to know whether you manage to resolve this issue…