Error while loading native library with base name "JCudaDriver"

Hello,

I’m new to CUDA and jCuda, and am having problems with JCudaDriver loading in running samples. Using the emulation mode, I’ve gotten the JCudaRuntimeSample.java to run fine, but when I run both the KernelLauncherSample.java and the JCudaDriverCubinSample.java, I get the following error:

[SIZE=2][LEFT]Error while loading native library with base name “JCudaDriver”
Operating system name: Windows XP
Architecture : x86
Architecture bit size: 32
Stack trace:
java.lang.UnsatisfiedLinkError: C:\Java\workspace\jCuda\JCudaDriver-windows-x86.dll: Can’t find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load([/SIZE][SIZE=2]Native Method[/SIZE][SIZE=2])
at java.lang.ClassLoader.loadLibrary0([/SIZE][SIZE=2]ClassLoader.java:1758[/SIZE][SIZE=2])
at java.lang.ClassLoader.loadLibrary([/SIZE][SIZE=2]ClassLoader.java:1683[/SIZE][SIZE=2])
at java.lang.Runtime.loadLibrary0([/SIZE][SIZE=2]Runtime.java:823[/SIZE][SIZE=2])
at java.lang.System.loadLibrary([/SIZE][SIZE=2]System.java:1028[/SIZE][SIZE=2])
at jcuda.LibUtils.loadLibrary([/SIZE][SIZE=2]LibUtils.java:53[/SIZE][SIZE=2])
at jcuda.driver.JCudaDriver.([/SIZE][SIZE=2]JCudaDriver.java:82[/SIZE][SIZE=2])
at samples.KernelLauncherSample.main([/SIZE][SIZE=2]KernelLauncherSample.java:28[/SIZE][SIZE=2])[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#000000]I’m guessing i’m missing something simple, but not sure where to start. Any help in figuring this out would be much appreciated! [/COLOR][/SIZE]
[SIZE=2][COLOR=#000000] [/LEFT]
[/COLOR][/SIZE]

Hello

In any case, to use CUDA/JCuda in non-emulation mode, you have to install the appropriate driver and the CUDA toolkit. The current version of the toolkit may be obtained from http://www.nvidia.com/getcuda BUT NOTE that NVIDIA has updated to CUDA 3.0 few days ago, and the binaries of JCuda are compiled for version 2.3 - so they will probably not run with the latest version! I’m currently working on the update of JCuda for CUDA 3.0, and the first updated version (including binaries for 32bit Windows) will be available soon, hopefully I’ll manage to upload them by next week.

bye
Marco

EDIT: Alternatively, if you have Visual Studio and the CUDA driver, toolkit and SDK installed, you may want to try compiling the binaries of JCuda 0.2.3 using your CUDA 3.0 installation. It should be possible, although I can not make any promises that it will work…

Hi Marco,

Thanks for the reply. I was running in emulation since I don’t have a device on this computer. I do have the toolkit and SDK installed, but with further poking around, it appears it was trying to find the nvcuda.dll driver even in the emulation mode. I then read on the jcuda website that the emulation mode does not support the driver API, so i’m guessing that’s where my problem arose.

Coincidentally, I tried running the samples on my other machine which does have a device, and it threw an error about not nvcc not finding cl.exe on the PATH. Does jCuda require VS installed to run? Is that true for CUDA too? Or can you configure to use gcc toolchain?

Thanks for the heads up about Cuda 3.0. Any estimates on when the 64bit binary will be available?

Thanks

Hi

Yes, the driver API of CUDA does not support emulation mode. And with CUDA 3.0, the emulation mode will be „deprecated“, that is, it will also no longer be officially available in the Runtime Libraries.

JCuda does NOT require Visual Studio to be installed. I assume that the error „nvcc not finding cl.exe on the PATH“ happened in the „KernelLauncher“ example. This single example (and ONLY this example) requires a C compiler to be installed, since it compiles CUDA source code at runtime. I could only test this with Windows XP and Visual studio, but it should be possible to adjust it so that it may run on Linux and MacOS as well.

The KernelLauncher basically creates and executes a command line to call the „NVCC“ (NVIDIA CUDA Compiler), which creates the „CUBIN“ (CUDA Binary) file for the CUDA source code that is stored as a String inside the program. This happens in the „prepareCubinFile“ method. You may try to adjust the command line so that your installation of the NVCC is found. The NVCC itself calls „any“ C compiler, which can either be the Visual Studio compiler, or the GCC. This can also be specified as an argument for the NVCC. You may also want to have a look at the NVCC documentation, which can be found in the „CUDA\doc“ directory, to figure out the appropriate command line.

Alternatively, in any case, you may create the CUBIN file by adding the „-keep“ parameter to the NVCC call, and apart from that, the program may be compiled as usual. The CUBIN file can then be loaded using the driver API or with the KernelLauncher#load method.

But to emphasize this: The KernelLauncher example is NOT a part of the JCuda API. It should only (basically) demonstrate, how you could compile and run inlined source code, and simplify the Kernel calls. Once it is more „mature“, it might be integrated into some „Utilities“ package, but at the moment it should be considered ONLY as an example or „proof of concept“.

Concerning the update for CUDA 3.0: I will hopefully be able to finish most of the work on the source code this week. The binaries for Windows 32 will most likely be available next week, the binaries for Linux 32 and for Windows 64 in 1 or 2 weeks. For all other configurations, I rely on interested users who like to contribute by compiling the binaries for their target platforms (or on donations, so that I can buy my own set of 64bit machines for Windows, Linux and MacOS :wink: )

Hi Marco,

Thanks again for your timely response!

I do like the KernelLauncher idea; a Utility class down the line would be nice.

Without Visual Studio, the official error string from attempts to compile with nvcc is „Cannot find compiler ‚cl.exe‘ in PATH“. I tried adding ‚–foreign‘ argument to the nvcc command to switch to gcc, but that gave other path-related errors. Googling around, it appears there may be some workarounds (http://forums.nvidia.com/lofiversion/index.php?t78531.html), but haven’t tried yet, and last post within states the cl.exe compiler is necessary for windows. Along with reading up on CUDA documentation, since i’ve just started, I guess I could make it easy on myself and reinstall VS2008…too bad I had just uninstalled it!

Thanks :slight_smile:

Hello,

There are indeed some aspects for CUDA programming that may be tedious, so there certainly is the demand for some utility methods. I thought about a package containing, for example, some of the “CUTIL” functions of the NVIDIA CUDA samples, and possibly some more, like the KernelLauncher.

I just had another look at the NVCC documentation, and it seems that in the latest version, the NVCC only supports the VS CL on Windows (and no longer a GCC-like environment like mingw or something). I wonder if there will be an integrated compiler in one of the next versions of CUDA. The support for that is basically already available in the OpenCL part of the NVIDIA SDK, so this should be possible, at least…

Hope that it will work after the installation of VS2008

bye
Marco

PS: I just uploaded the source and Win32 binaries for JCuda 0.3.0, targeting CUDA 3.0. Although I have some doubts, because I could not yet test the compilation under Linux, but I’ll hopefully have the chance to test this soon.