Executing CUDA or PTX Code on the GPU

조회 수: 6 (최근 30일)
Darryl
Darryl 2011년 5월 18일
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

답변 (3개)

Edric Ellis
Edric Ellis 2011년 5월 19일
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
Edric Ellis
Edric Ellis 2011년 5월 20일
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
Darryl
Darryl 2011년 6월 28일
Thanks!!! -m 64 was the right method to solve this program!

댓글을 달려면 로그인하십시오.


Gaszton
Gaszton 2011년 5월 19일
"??? 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
  댓글 수: 1
Darryl
Darryl 2011년 5월 19일
I checked the compiling. I recompiled if there is any modification in the code. I tried as what you said.
I don't know why, but it stil keep showing the error message.
??? 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

댓글을 달려면 로그인하십시오.


King Fisher
King Fisher 2011년 11월 27일
I have exactly the same problem :(

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by