Michael IV
Michael IV

Reputation: 11496

Can't find neither .cubin nor .ptx file compiling CUDA

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.

Upvotes: 2

Views: 1441

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 152143

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.

Upvotes: 2

Related Questions