I occur an exception after running the KernelLaucherSample.java
Preparing the KernelLauncher...
Exception in thread "Main Thread" jcuda.CudaException: CUDA_ERROR_INVALID_SOURCE
at jcuda.driver.JCudaDriver.checkResult(JCudaDriver.java:153)
at jcuda.driver.JCudaDriver.cuModuleLoad(JCudaDriver.java:754)
at KernelLauncher.init(KernelLauncher.java:377)
at KernelLauncher.create(KernelLauncher.java:294)
at KernelLauncher.create(KernelLauncher.java:237)
at KernelLauncher.compile(KernelLauncher.java:201)
at KernelLauncherSample.main(KernelLauncherSample.java:36)
I checked the exception is occur in KernelLauncher.init function. It may be the problem of
cuModuleLoad(module, cubinFileName);
The JCuda Driver is Version 0.3.0a and the Cuda Driver setting is:
Device 0: "GeForce GTX 470"
CUDA Driver Version: 3.10
CUDA Runtime Version: 3.10
CUDA Capability Major revision number: 2
CUDA Capability Minor revision number: 0
Unfortunately, the CUDA documentation is kind of ridiculous in this point: Despite the fact that the CUDA_ERROR_INVALID_SOURCE error is not listed as the return value of any of the functions, and there is in general no description about the conditions under which a certain error code is returned, the only decumentation of this error code is
CUDA_ERROR_INVALID_SOURCE : Invalid source.
Yes, I already thought that it could be something like this :twisted:
However, did you use the original, unmodified KernelLauncherSample, with the original, unmodified Source Code? If you have modified the source code, you might have introduced an error…
EDIT: Hey, wait a moment: The CUDA driver is version 3.1, but you mentioned JCuda 0.3.0a. If you have the CUDA Version 3.1, you should use JCuda 0.3.1.
Using both JCuda 0.3.0a version and the unmodified code of KernelLauncherSample.java and KernelLauncher.java, the same exception occur.
While I upgrade JCuda 0.3.1 version, I import jxxx-0.3.1.jar rather than jxxx-0.3.0a.jar and also I replace the .so file from JCuda-All-0.3.1-bin-linux-x86_64 (i hope that i haven’t miss other steps).
However, the same exception of KernelLauncherSample occur.And also, I failed to run the JCudaRuntimeSample.java
Creating input data
Initializing device data using JCuda
Performing FFT using JCufft
Performing caxpy using JCublas
Performing scan using JCudpp
Error while loading native library with base name "JCudpp"
Operating system name: Linux
Architecture : amd64
Architecture bit size: 64
Exception in thread "Main Thread" java.lang.UnsatisfiedLinkError: Could not load native library
at jcuda.LibUtils.loadLibrary(LibUtils.java:79)
at jcuda.jcudpp.JCudpp.assertInit(JCudpp.java:175)
at jcuda.jcudpp.JCudpp.cudppPlan(JCudpp.java:214)
at JCudaRuntimeSample.main(JCudaRuntimeSample.java:89)
Is the libJCudpp-linux-x86_64.so built from cudpp v1.1.1 ??
The other native libraries except for JCudpp seem to work. I have contacted the person who provided the binaries for Linux 64, maybe he has an idea what might be wrong there.
So a quick fix might be to just create the symb. links.
In how far does your setup differ from the one described above, concerning the files in „/usr/local/cuda/lib64/“? Maybe creating these links can help to get it running?
As I mentioned: This is not my setting, but the setting of the contributor who provided the binaries for Linux 64.
But it seems it is mainly missing the “libcudpp.so”. If you have the NVIDIA CUDA SDK installed, it should contain the appropriate CUDPP library. (Under windows it’s in
NVIDIA GPU Computing SDK\C\bin\win32\Release\cudpp32_31_9.dll
maybe you can find it at a similar place in your Linux installation).
Maybe it’s enough to copy the .SO file from the SDK into the cuda/lib64 directory?
Yes Marco is right, you need to put the cudpp shared library in your /usr/loca/cuda/lib64 (for 64 bit) folder and create a symbolic link to the different names, in particular:
$ sudo ln -s libcudpp.so.1.1.1 libcudpp.so
cudpp comes as a static library with the linux SDK code samples from nvidia, and one could link it statically when creating libJCudpp-linux-x86_64.so, but the problem is that this static library is around 90 MB!
So I compiled cudpp into a shared lib. from the source and put it in /usr/local/cuda/lib64/ together with the symbolic links.
If you cannot be bothered to compile cudpp as a shared lib yourself, then you can download the one I have for 64bit linux version 1.1.1 from here:
Maybe kashif gan give a more precise and profound hint there, but … you might try the same procedure (“sudo ln…”) with the libtcutil.so. A version of the libcutil should definitely be in the SDK.
Opps you are right I forgot that it also needs the libcutil which i compiled as a shared lib. I have now linked libcutil as a static lib. into my libcudpp.so so please download it again from here:
ps. so sorry about the ln -s confusion… that was just to show u how to create links to the name of the lib that it was expecting… but if you have just libcudpp.so then you dont need to do that.
Thanks to kashif for the support here, I’d be lost otherwise… :o
I did a quick websearch on “cuModuleLoad CUDA_ERROR_INVALID_SOURCE”, and found this thread - you might want to try adding the “-sm_20” argument to the NVCC:
System.out.println("Preparing the KernelLauncher...");
KernelLauncher kernelLauncher =
KernelLauncher.compile(sourceCode, "add"**, "-sm_20"**);
I’m still sticking with my “old” GeForce 8800, so I’m not always aware of any CC 2.0 issues…
Note that the kernel must be written appropriately, so that you can really use the respective block size.
You may query the maximum block size. There is not yet a device query example in JCuda, but you may have a look at the NVIDIA CUDA device query example which shows how it basically works. If you have difficulties converting it to JCuda, you might want to have a look at the JOCLDeviceQuery.java sample, which is for JOCL instead of JCuda, but with JCuda it should be quite similar.
If it does not work, maybe I’ll find the time to port the device query example to JCuda.