Windows – Converting CUDA .cu file to PTX file

cudaptxvisual studiowindows

I am having problem converting .cu to .ptx. I am using nvcc as follows:

"C:\ Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc" -ptx -ccbin "C:\ Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -o foo.ptx foo.cu

The following is displayed in return:

foo.cu
c1xx : fatal error C1083: cannot open source file: 'foo.cu': No such file or directory

foo.cu is located in the \CUDA\v5.0\bin.

Best Answer

Go to the Project Properties in Visual Studio 2010. In CUDA C/C++, in Common change the property Keep Preprocessed Files to Yes(--keep). Build the project. You should be able to see the .ptx file in folder as C:/Users/Mansoor/Documents/Visual Studio 2010/Projects/Testing_PTX/x64/Debug depending on the configuration (x32 or x64). If your .cu filename was TestingPTX.cu then the filename for PTX file would be TestingPTX.compute_xx.ptx where xx is the compute capability defined in your project properties. For multiple compute capability options there will be a dedicated .ptx file. The content of a typical PTX file can be seen at pastebin.com It is very straight forward but took me quite some time to figure out because there is not much material over the internet regarding generation of .ptx within the Visual Studio environment. Hope it will help the newbies like me.

Related Topic