Executing CUDA or PTX Code on the GPU
1 view (last 30 days)
Show older comments
Hello,
I have a question regarding to CUDA code on the GPU.
I use Matlab 2011a parallel tool kit trial version, VS 2008 and CUDA 3.2.
I just tried to compile the sample CUDA code from parallel tool kit tutorial. (Following is the CUDA kernel code)
File name: test.cu global void add1( double * pi, double c ) { *pi += c; }
I just tried to compile by using following command as described in tutorial.
nvcc -ptx test.cu
but it showed me following error message.
nvcc fatal : Visual Studio configuration file 'vsvars32.bat' could not be foun d for installation at './../../..'
I could fix this error message by using following command
nvcc -ccbin "C:\Program Files (x86)\Mic rosoft Visual Studio 9.0\VC\bin" -I"C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include" -ptx test.cu
Then, I could get the test.ptx file and
I just tried to excute this file by using following command.
k=parallel.gpu.CUDAKernel('test.ptx', 'test.cu');
But, it is not runnable. I see this error message.
Could you tell me what should I do to run this code?
??? Error using ==> iCheckPTXEntryAgainstCProto at 384 The number of inputs to the PTX code (2) is NOT the same as the number of inputs in the C prototype (0)
Error in ==> C:\Program Files\MATLAB\R2011a\toolbox\distcomp\gpu\+parallel\+internal\+gpu\handleKernelArgs.p>handleKernelArgs at 81
0 Comments
Answers (3)
Edric Ellis
on 19 May 2011
I'm not quite sure why that's failing, but you may be able to work around that by constructing the kernel like so:
k = parallel.gpu.CUDAKernel( 'test.ptx', 'double *, double' )
(The formatting of your "test.cu" is hasn't come out right above - we attempt to parse the prototype from the .cu code, and perhaps something is confusing our parsing...)
3 Comments
Edric Ellis
on 20 May 2011
It should have nothing to do with a trial version. Also, if you're running on a 64-bit platform, you might need to compile the PTX in 64-bit mode by adding "-m 64" to your nvcc command-line
Gaszton
on 19 May 2011
"??? Error using ==> iCheckPTXEntryAgainstCProto at 384 The number of inputs to the PTX code (2) is NOT the same as the number of inputs in the C prototype (0)"
i got this error when my .ptx file was not recomplied after modifying the .cu source file
Other tip: I suggest you, to modify the nvcc profile file, located here: ...\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\
put this extras in it:
#
# Location of Microsoft Visual Studio compiler
#
compiler-bindir = d:\Programs\Microsoft Visual Studio 9.0\VC\bin
include-path = "d:\Programs\Microsoft Visual Studio 9.0\VC\include"
(Copy paste the path of your VStudio folder)
I dont know why, but the "include-path" has no effect, so you still have to specify the VS include directory to nvcc.
I you want to avoid typing it in the cmd, create a .bat batch file:
@ECHO OFF
cmd /k nvcc -I "D:\programs\Microsoft Visual Studio 9.0\VC\include" -gencode=arch=compute_20,code=\"sm_21,compute_20\" -ptx yourcudacode.cu
See Also
Categories
Find more on GPU Computing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!