Could not prepare CUBIN for source file

Hi ?
I am new in using jcuda to access cuda kernels. I have a problem the KernelLauncherSample.java class

Here is the error message:

Preparing the KernelLauncher…
Exception in thread “main” jcuda.CudaException: Could not prepare CUBIN for source file ‘C:\Users\LINUXC~1\AppData\Local\Temp emp_JCuda_7067568976632352196.cu’
at jcuda.utils.KernelLauncher.create(KernelLauncher.java:389)
at jcuda.utils.KernelLauncher.create(KernelLauncher.java:321)
at jcuda.utils.KernelLauncher.compile(KernelLauncher.java:270)
at KernelLauncherSample.main(KernelLauncherSample.java:44)

I am working with: - Windows 7 as operating system
- I have an NVIDIA GeForce GTX 460
- CUDA Toolkit 3.2.16
- SDK version 3.2.16 also
- JCuda-All-0.3.2-bin-windows-x86
- I install the CUDA Driver, and it’s working perfectly
- eclipse 3.6
- I added all the necessary files to the build path including the jcudaUtils-0.0.2.jar file
- I copy all the .dll files in the project’s directory

help me please
Thanks

Hello,

It’s a pity: For exactly this one line, the nested exception is missing (the error is caused by an IOException, but it’s not shown which IOException…). I’ll update the KernelLauncher class accordingly as soon as possible.

But for a first quick test, you might try the following:

  • Extract the “KernelLauncher.java” from the JCuda utils package
  • Change the line 389 of the KernelLauncher.java from

        catch (IOException e)
        {
            throw new CudaException(
                "Could not prepare CUBIN for source file '"+cuFileName+"'");
        }

to


        catch (IOException e)
        {
            throw new CudaException(
                "Could not prepare CUBIN for source file '"+cuFileName+"'"**, e**); // Pass 'e' as cause for the exception here
        }

  • Use this updated class instead of the one from the Utilities package (I think it should be “standalone”, not other classes required)

This should cause the Error message to be extended by a block like


...
caused by:
    IOException at ... 

hopefully including a message that helps to find the error.

I wonder what can go wrong when trying to read a file from the local file system (since writing the file seems to have worked!), but maybe the message of the IOException brings some insights.

If it’s urgent and does not work, you may also consider putting the CUDA code into a file in your local project directories, and load it from there (this should not be necessary, but may be a workaround for now)

bye
Marco

OK Thanks a lot Marco.

More precision on the error message will give me further information of what’s wrong.

I’ll try that and keep you informed, in case I’m still stuck.

linuxciscoarnaud.

Hi ?
I still have a problem. Extract the file “KernelLauncher.java” means i should import it within a java project, make the modifications , and then export it back (recreate a corresponding jar file) so that i can use it to figure out what’s wrong with the “KernelLauncherSample.java” class.
I have imported it successfuly, but since yesterday, i have been try to recreate a jar file and it’s not working, I have the following message:

JAR creation failed. See details for additional information.
jcuda/utils [in jcudaUtils-0.0.2] is not on its project’s build path
Unable to get package fragment root: jcudaUtils-0.0.2/jcuda/utils/KernelLauncher.java
jcuda/utils [in jcudaUtils-0.0.2] is not on its project’s build path

I don’t know what to do

Bye
Linuxciscoarnaud

Maybe there is another way to extract the “KernelLauncher.java” from the JCuda utils package. Please if someone on this forum know how to do it, just tell me. That will help me a lot. Thanks

linuxciscoarnaud

Hello,

There should be no need to create the JAR file again. The current JAR file contains the KernelLauncher.java. You can add this KernelLauncher.java to your project, just like any other .java file - the easiest might be to add it in the same package as the class which is using the KernelLauncher. (After you have added this single JAR file, you may probably remove the Utilities JAR, if you don’t use any other classes from it.)
If it does not work: I can upload the updated Utilities package early this week.

bye

Tanks a lot for your help Marco.
I did as you said and now here are the information about the error message :

Preparing the KernelLauncher…
Exception in thread “main” jcuda.CudaException: Could not prepare CUBIN for source file ‘C:\Users\LINUXC~1\AppData\Local\Temp emp_JCuda_5248357859698980303.cu’
at KernelLauncher.create(KernelLauncher.java:388)
at KernelLauncher.create(KernelLauncher.java:320)
at KernelLauncher.compile(KernelLauncher.java:269)
at KernelLauncherSample.main(KernelLauncherSample.java:44)
Caused by: java.io.IOException: Cannot run program “nvcc”: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at KernelLauncher.prepareCubinFile(KernelLauncher.java:1122)
at KernelLauncher.create(KernelLauncher.java:384)
… 3 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
… 9 more

Maybe the nvcc.exe file is not well configurated in the Path. I’ll try to check, but if you have any other explantion, just let me know.

Thanks LOT

Bye
Linuxciscoarnaud

Ok I was right.

I configurated the nvcc.exe file in the Path, and the nvcc.exe file began the compilation of the .cu file, until another error. This time, here is the message :

Preparing the KernelLauncher…
2011?3?28? ??07:08:52 KernelLauncher prepareCubinFile
???: errorMessage:
temp_JCuda_1478454343652004620.cu
Internal error: assertion failed at: “D:/Bld/rel/gpgpu/toolkit/r3.2/compiler/edg/EDG_4.1/src/host_envir.c”, line 4452

1 catastrophic error detected in the compilation of “C:/Users/LINUXC~1/AppData/Local/Temp/tmpxft_00000c78_00000000-6_temp_JCuda_1478454343652004620.cpp4.ii”.
Compilation aborted.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.

2011?3?28? ??07:08:52 KernelLauncher prepareCubinFile
???: outputMessage:

Exception in thread “main” jcuda.CudaException: Could not create .cubin file: temp_JCuda_1478454343652004620.cu
Internal error: assertion failed at: “D:/Bld/rel/gpgpu/toolkit/r3.2/compiler/edg/EDG_4.1/src/host_envir.c”, line 4452

1 catastrophic error detected in the compilation of “C:/Users/LINUXC~1/AppData/Local/Temp/tmpxft_00000c78_00000000-6_temp_JCuda_1478454343652004620.cpp4.ii”.
Compilation aborted.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.

at KernelLauncher.prepareCubinFile(KernelLauncher.java:1144)
at KernelLauncher.create(KernelLauncher.java:384)
at KernelLauncher.create(KernelLauncher.java:320)
at KernelLauncher.compile(KernelLauncher.java:269)
at KernelLauncherSample.main(KernelLauncherSample.java:44)

bye
linuxciscoarnaud

Uh-hu… „catastrophic error“ does not sound sooo good :wink: -_-

The error message seems to come from somewhere deeply inside the NVCC compiler, and it seems (!) that it is not directly related to JCuda or the KernelLauncher. But maybe it’s possible to find the error. Which sort of kernel are you trying to compile? Could it be replaced by an „empty“ kernel to see whether the compilation itself works or whether it’s caused by the contents of the kernel? Or can you try compiling the .CU file manually from the console? This might help to track down the error a little bit…

HI Marco13 ?

You was right, the error is somewhere deeply inside the NVCC compiler, i tried to compile .cu mannually in the command line, but i am still
having the same error message :

temp_JCuda_1478454343652004620.cu
Internal error: assertion failed at: “D:/Bld/rel/gpgpu/toolkit/r3.2/compiler/edg/EDG_4.1/src/host_envir.c”, line 4452

1 catastrophic error detected in the compilation of “C:/Users/LINUXC~1/AppData/Local/Temp/tmpxft_00000c78_00000000-6_temp_JCuda_1478454343652004620.cpp4.ii”.
Compilation aborted.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.

2011?3?28? ??07:08:52 KernelLauncher prepareCubinFile
???: outputMessage:

Exception in thread “main” jcuda.CudaException: Could not create .cubin file: temp_JCuda_1478454343652004620.cu
Internal error: assertion failed at: “D:/Bld/rel/gpgpu/toolkit/r3.2/compiler/edg/EDG_4.1/src/host_envir.c”, line 4452

1 catastrophic error detected in the compilation of “C:/Users/LINUXC~1/AppData/Local/Temp/tmpxft_00000c78_00000000-6_temp_JCuda_1478454343652004620.cpp4.ii”.
Compilation aborted.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.

at KernelLauncher.prepareCubinFile(KernelLauncher.jav a:1144)
at KernelLauncher.create(KernelLauncher.java:384)
at KernelLauncher.create(KernelLauncher.java:320)
at KernelLauncher.compile(KernelLauncher.java:269)
at KernelLauncherSample.main(KernelLauncherSample.jav a:44)

I think something is wrong with my windows 7 environment, so I changed the working environment. I am working now with the linux environment,
more particularly Mandriva Spring 2010.1. I downloaded and installed all the required software from the NVIDIA website :

  • CUDA Toolkit for Fedora 13 : cudatoolkit_3.2.16_linux_32_fedora13.run (compatible with Mandriva 2010.1)
  • The driver : devdriver_3.2_linux_3.2_260.19.26.run
  • The SDK

Also i made all the necessary configuration

This time when I run the KernelLauncherSample.java class, the file .cu is compiled and the .Cubin file is even created, but i do have
the following error message :

Preparing the KernelLauncher…
Exception in thread “Main Thread” jcuda.CudaException: CUDA_ERROR_INVALID_SOURCE
at jcuda.driver.JCudaDriver.checkResult(JCudaDriver.j ava: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.jav a:36)

Thanks
linuxciscoarnaud

I have GTX460(I’m running WinXP) and I was getting (I guess) similar error(the .cubin was also created):
Exception in thread “main” jcuda.CudaException: CUDA_ERROR_INVALID_SOURCE
at jcuda.driver.JCudaDriver.checkResult(JCudaDriver.java:170)
at jcuda.driver.JCudaDriver.cuModuleLoadDataEx(JCudaDriver.java:1613)
at jcuda.utils.KernelLauncher.initModule(KernelLauncher.java:688)
at jcuda.utils.KernelLauncher.create(KernelLauncher.java:395)
at jcuda.utils.KernelLauncher.create(KernelLauncher.java:321)

The solution was to compile kernel with “-arch sm_20”. That’s for fermi devices(or rather for devices of compute capability 2.0 and higher)…

Hello,

That’s right, the CUBIN that is created may not match the target achitecture (see also the lower half of this post: http://forum.byte-welt.de/showpost.php?p=14560&postcount=4 : you may have to add the “-arch sm_21” parameter)

As mentioned in this post, it should not be necessary to do this manually, and I’ll try to extend the KernelLauncher appropriately. But at the moment I’m (on a meeting and not on my PC anyhow, and apart from that) quite busy with the update to CUDA 4.0: They changed a lot of the Kernel Invocation there, so there will definitely be an updated version of the KernelLauncher as soon as JCuda 0.4.0RC is published.

bye

Thank to you both.

I added the “-arch sm_21” argument when calling the compile method of the KernelLauncher class, and now it works perfectly.

Thanks

Bye
linuxciscoarnaud