1
votes

I am working on CUDA (7.0) project using Visual Studio 2013. The project is 64bit. I am using driver API and need to load module from ptx or cubin file.But I can't find the file. In VS I go Properties->CUDA C/C++ ->Common->NVCC Compilation Type ,change it to -cubin or ptx .the compiler finishes ok but I can't find that file.I only can see kernel.cu.obj and kernel.cu.cache files in output debug directory.What can be wrong here?

UPDATE:

If I go to Properties->CUDA C/C++ ->Common->Keep Preprocessed Files and set YES.Then I see .ptx,and other intermediate stuff.But as far as I understand this option is not mandatory to get .ptx?Also demo CUDA SDK projects like "matrixMulDrv" spitr ptx with that option off.I can't figure out where is the difference.

Here is matrixMulDrv project compile command:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\0_Simple\matrixMulDrv>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"compute_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 -ptx -cudart static -Xcompiler "/wd 4819" -o data/matrixMul_kernel64.ptx "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\0_Simple\matrixMulDrv\matrixMul_kernel.cu"

And here is my project CUDA kernel compile command:

E:\Documents\visual studio 2012\Projects\ProjectName\ProjectName>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64" -I"E:\Documents\visual studio 2012\Projects\XXXXXX\XXXXX\XXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXX\XXXXX\XXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXXXX\XXXXXXX\XXXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXXX\include" -I"E:\Documents\visual studio 2012\Projects\ProjectName\ProjectName\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXX\XXXXXX\XXXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXXX\XXXXXX\XXXXXX\include" -I"E:\Documents\visual studio 2012\Projects\XXXXXX\XXXXXX\XXXXXX\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0/include" -I"C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\common\inc" -I"E:\Documents\visual studio 2012\Projects\ProjectName\ProjectName\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g
-DWIN32 -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o x64\Debug\skernel.cu.obj "E:\Documents\visual studio 2012\Projects\ProjectName\ProjectName\src\skernel.cu"

It is possible to see that matrixMulDrv project is set to compile .ptx with this line data/matrixMul_kernel64.ptx while in my project I have -o x64\Debug\skernel.cu.obj .But I have the same CUDA compiler settings on both projects.

1
Have you tried looking at the VS console output closely during compilation? In my experience it always identifies the full path of objects it is creating. Have you tried using the windows file search function to look for new .ptx or .cubin files created after the compilation?Robert Crovella
Yes I did try it all.I just can't find those files in the file system.Michael IV
I suggest pasting the entire output from a VS compile command into your question. Set the VS output verbosity to high. If you don't know how to do that, please google for it. It's in one of the VS menu options. There are also various CUDA sample codes that generate ptx or cubins, such as matrixMulDrv. Try building one of those and see if you can find the ptx output (matrixMulDrv compile creates a matrixMul_kernel64.ptx file, for example.) If you can locate that file, then compare the differences between that project and yours.Robert Crovella
matrixMulDrv does spit ptx into a "data" folder .But I can't find the config that is responsible.Michael IV
For your file skernel.cu, in the solution explorer window on the right hand side of VS console, select that file, then right click and select properties. In the dialog box that opens up, select "CUDA C/C++" and look at the right hand side. What is displayed next to "Compiler Output (Obj/cubin)" and next to "NVCC Compilation Type" ? In this last position, I'm pretty sure your skernel.cu file has "Generate hybrid object file (--compile)" when it should be "Generate .ptx file (-ptx)" You'll need to do this detail level comparison of project differences between your project and the matrixMuldrvRobert Crovella

1 Answers

2
votes

CUDA projects in Visual Studio can inherit compile settings both at the project level (in which case they are defined in Project Properties...CUDA...Device) and at the file level (in which case you can right click on the file to bring up its properties and find them in a similar location).

The file can inherit its settings from the global project settings, or it can replace them (if you so select at the file level).

Some of those settings will determine what type of output will be generated (and therefore effectively what compile switches are needed) when that file is compiled by nvcc. Ordinary CUDA runtime API projects need their modules compiled into ("hybrid") object files (i.e. .o), but CUDA driver API projects will typically need cuda "objects" in the form of a .cubin file or a .ptx file.

There are settings to modify this generation, and for example to switch a file from typical CUDA runtime API compilation to typical driver API compilation, you could change the "NVCC Compilation Type" option from "Generate hybrid object file (--compile)" to "Generate .ptx file (-ptx)"

If you do this at the file level, it will need to be done for each file that needs its settings changed.