I want to develop by JCuda

Hi
I want to develop by JCuda~
But I don’t know what shall I do before Coding ~
The JCuda Enviroment doesn’t work well and always have this Error

Error while loading native library with base name “JCudaDriver”
Operating system name: Windows XP
Architecture : x86
Architecture bit size: 32
Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load native library
at jcuda.LibUtils.loadLibrary(LibUtils.java:74)
at jcuda.driver.JCudaDriver.(JCudaDriver.java:96)
at JCudaDriverInit.main(JCudaDriverInit.java:13)

I have read the tips how to solve this problem,but still fail~
I don’t know which is the right steps to build the JCuda Enviroment~
Would please tell which need to install and the right order~

Thanks!

Hello,

Some information could make it easier to help you:

  • Which Operating System / Architecture do you have? (According to the stack trace it should be Windows XP 32bit)
  • Do you have installed the CUDA developer drivers and toolkit of CUDA 3.1 ? (See http://developer.nvidia.com/object/cuda_3_1_downloads.html )
  • Some details about your setup (where did you put the DLLs?)

I also wrote how to set up a minimum JCuda Project which might help over this first hurdle…

bye
Marco

[QUOTE=Marco13]Hello,

Some information could make it easier to help you:

  • Which Operating System / Architecture do you have? (According to the stack trace it should be Windows XP 32bit)
  • Do you have installed the CUDA developer drivers and toolkit of CUDA 3.1 ? (See http://developer.nvidia.com/object/cuda_3_1_downloads.html )
  • Some details about your setup (where did you put the DLLs?)

I also wrote how to set up a minimum JCuda Project which might help over this first hurdle…

bye
Marco[/QUOTE]

Hi Marco
it still doesn’t work ~
I installed CUDA developer drivers and toolkit of CUDA 3.1 in a default path,do they need to be set in a special path?and after installing,should I configure something?
and wherever I put the DLLs, fail…
What shall I do ?
On My Frist Hello World~:(

Hello

Did you follow the steps how to set up a minimum JCuda project? Does it still print the same error message?

bye
Marco

[QUOTE=Marco13]Hello

Did you follow the steps how to set up a minimum JCuda project? Does it still print the same error message?

bye
Marco[/QUOTE]
Hi

Pointer: Pointer[nativePointer=0x0,byteOffset=0]

it output this message,but other examples output error messages~

Hi~
Look at a sample from website

import java.util.Random;
import java.util.Arrays;

import jcuda.Pointer;
import jcuda.Sizeof;
import jcuda.jcudpp.*;
import jcuda.runtime.JCuda;
import jcuda.runtime.cudaMemcpyKind;

public class test {

//@Test
public void test01() throws Exception {
    int size=100000;
    int[] data1=createRandomIntData(size);
    int[] data2=data1.clone();
    long start=System.currentTimeMillis();
    Arrays.sort(data1);
    long use=System.currentTimeMillis()-start;
    System.out.printf("Java Quick Sort use %d ms

",use);
start=System.currentTimeMillis();
sort(data2);
use=System.currentTimeMillis()-start;
System.out.printf("In Cuda Sort use %d ms
",use);
boolean same=Arrays.equals(data1,data2);
if(!same) {
System.out.println(“but data not equals”);
}
}

private static int[] createRandomIntData(int n) {
    Random random = new Random(0);
    int x[] = new int[n];
    for (int i = 0; i < n; i++) {
        x** = random.nextInt(Integer.MAX_VALUE);
    }
    return x;
}

private void sort(int array[]) {
    int n = array.length;

    // Allocate memory on the device
    Pointer d_in = new Pointer();
    Pointer d_out = new Pointer();
    JCuda.cudaMalloc(d_in, n * Sizeof.INT);
    JCuda.cudaMalloc(d_out, n * Sizeof.INT);
    // Copy the input array from the host to the device
    JCuda.cudaMemcpy(d_in, Pointer.to(array), n * Sizeof.INT,
            cudaMemcpyKind.cudaMemcpyHostToDevice);
    // Create a CUDPPConfiguration for a radix sort of
    // an array of ints
    CUDPPConfiguration config = new CUDPPConfiguration();
    config.algorithm = CUDPPAlgorithm.CUDPP_SORT_RADIX;
    config.datatype = CUDPPDatatype.CUDPP_INT;
    config.op = CUDPPOperator.CUDPP_ADD;

    long start=System.currentTimeMillis();
    // Create a CUDPPHandle for the sort operation
    CUDPPHandle handle = new CUDPPHandle();
    JCudpp.cudppPlan(handle, config, n, 1, 0);

    // Execute the sort operation
    JCudpp.cudppSort(handle, d_out, d_in, n, 0);

    System.out.printf("Core use %d ms

",System.currentTimeMillis()-start);

    // Copy the result from the device to the host
    JCuda.cudaMemcpy(Pointer.to(array), d_out, n * Sizeof.INT,
            cudaMemcpyKind.cudaMemcpyDeviceToHost);

    // Clean up
    JCudpp.cudppDestroyPlan(handle);
    JCuda.cudaFree(d_in);
    JCuda.cudaFree(d_out);
}
public static void main(String[] args) throws Exception {
    new test().test01();
}

}

error message

Java Quick Sort use 16 ms
Error while loading native library with base name “JCudpp”
Operating system name: Windows XP
Architecture : x86
Architecture bit size: 32
Exception in thread “main” 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 test.sort(test.java:63)
at test.test01(test.java:22)
at test.main(test.java:81)


I put the .java document in the same directory with your sample~:(

Hello

Did you test one of the simple examples? You should first try the “minimal” example, or the JCublas sample. This will help to see whether your setup is working in general.

As described on the JCudpp site, for JCudpp you also need the native CUDPP library. This library is contained in the NVIDIA SDK. If you don’t want to install the SDK, I can try to upload the library for you - the library is not included in the JCuda package because it is ~50 MB large…

bye
Marco

[QUOTE=Marco13]Hello

Did you test one of the simple examples? You should first try the “minimal” example, or the JCublas sample. This will help to see whether your setup is working in general.

As described on the JCudpp site, for JCudpp you also need the native CUDPP library. This library is contained in the NVIDIA SDK. If you don’t want to install the SDK, I can try to upload the library for you - the library is not included in the JCuda package because it is ~50 MB large…

bye
Marco[/QUOTE]
Hi Marco

I tried the Jcublas sample,it seems ok,no error.
But the JCudppSample still didn’t work well
exception message:
Creating input data
Performing sort with Java…
Performing sort with JCudpp…
Error while loading native library with base name “JCudpp”
Operating system name: Windows XP
Architecture : x86
Architecture bit size: 32
Exception in thread “main” 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 JCudppSample.sort(JCudppSample.java:75)
at JCudppSample.testSort(JCudppSample.java:41)
at JCudppSample.main(JCudppSample.java:23)

and the JCufftSample needed edu.emory.mathcs.jtransforms.fft.FloatFFT_1D,and I haven’t find it ~
I installed the NVidia SDK,does it mean the “cudatoolkit_3.1_win_32.exe”?
I installed it in its default way C:\CUDA
and I also installed “devdriver_3.1_winxp_32_257.21_general.exe” in its default way

Thanks

Hello

Fine, when the JCublas sample is working, the setup is OK in general.

For JCudpp, you also need the CUDPP library. It is contained in the SDK, which is available at the NVIDIA download site as
“GPU Computing SDK code samples” (file name: gpucomputingsdk_3.1_win_32.exe)

It is quite large. If you don’t want to install it, I’ll upload the required library for you today as a separate ZIP file.

bye
Marco

[QUOTE=Marco13]Hello

Fine, when the JCublas sample is working, the setup is OK in general.

For JCudpp, you also need the CUDPP library. It is contained in the SDK, which is available at the NVIDIA download site as
“GPU Computing SDK code samples” (file name: gpucomputingsdk_3.1_win_32.exe)

It is quite large. If you don’t want to install it, I’ll upload the required library for you today as a separate ZIP file.

bye
Marco[/QUOTE]
Hi~Marco~
Thanks~
I’ll download the gpucomputingsdk_3.1_win_32.exe~
I wish I can fix it~
Thanks indeed~:)
Best Wishes

Hello

OK, I hope it will work as expected.

After the installation, the required cudpp DLL is in
NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\Release\cudpp32_31_9.dll

For a first test, you may copy it in the same directory as the other DLLs. Later you may want to use an alternative solution, like adjusting your PATH instead to point to the right directory.

bye
Marco

[QUOTE=Marco13]Hello

OK, I hope it will work as expected.

After the installation, the required cudpp DLL is in
NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\Release\cudpp32_31_9.dll

For a first test, you may copy it in the same directory as the other DLLs. Later you may want to use an alternative solution, like adjusting your PATH instead to point to the right directory.

bye
Marco[/QUOTE]

Hi ,Marco
It Works :smiley:
Thanks a lot!
Best Wishes!