Debugging CUDA代码在使用sm_35编译时运行,但在使用sm_30编译时失败
我拥有的GPU设备是GeForce GT 750M,我发现它是compute capability 3.0。我下载了这里的CUDA代码:(.它的makefile有标志-arch=sm_35 因为我的设备是compute capability 3.0,所以我将标志更改为-arch=sm_30。它编译得很好,但是当我运行代码时,我得到以下错误:Debugging CUDA代码在使用sm_35编译时运行,但在使用sm_30编译时失败,debugging,cuda,gpgpu,word2vec,Debugging,Cuda,Gpgpu,Word2vec,我拥有的GPU设备是GeForce GT 750M,我发现它是compute capability 3.0。我下载了这里的CUDA代码:(.它的makefile有标志-arch=sm_35 因为我的设备是compute capability 3.0,所以我将标志更改为-arch=sm_30。它编译得很好,但是当我运行代码时,我得到以下错误: word2vec.cu 449 : unspecified launch failure word2vec.cu 449 : unspecified la
word2vec.cu 449 : unspecified launch failure
word2vec.cu 449 : unspecified launch failure
它多次显示,因为有多个CPU线程启动CUDA内核。请注意,这些线程不使用不同的流来启动内核,因此内核启动都是有序的
现在,当我将标志设置为-arch=sm_35时,代码运行正常。有人能解释一下,当我将标志设置为与我的设备匹配时,为什么代码不会运行吗?因为这表明没有GeForce GTX 750M
你的是:
GeForce GTX 750钛
GeForce GTX 750
或
GeForce GT 750M
如果您的GPU是前两个GPU之一,那么您的GPU基于Maxwell,并且计算能力=5.0
否则,您的GPU基于开普勒,计算能力=3.0
如果你不确定你的GPU是什么,首先从英伟达的样本中运行DeViSeCuy来计算出来。
< P>不幸的是,你的结论是,当编译为Smi35时,代码在Smi30GPU上运行时,它是错误的。void cbow_cuda(long window, long negative, float alpha, long sentence_length,
int *sen, long layer1_size, float *syn0, long hs, float *syn1,
float *expTable, int *vocab_codelen, char *vocab_code,
int *vocab_point, int *table, long table_size,
long vocab_size, float *syn1neg){
int blockSize = 256;
int gridSize = (sentence_length)/(blockSize/32);
size_t smsize = (blockSize/32)*(2*layer1_size+3)*sizeof(float);
//printf("sm size is %d\n", smsize);
//fflush(stdout);
cbow_kernel<1><<<gridSize, blockSize, smsize>>>
(window, negative, alpha, sentence_length, sen,
layer1_size, syn0, syn1, expTable, vocab_codelen,
vocab_code, vocab_point, table, table_size,
vocab_size, syn1neg);
}
ie.内核启动失败,因为在应用程序中的CUDA cubin负载中找不到合适的设备代码。这也回答了您关于此代码输出不正确的原因。当使用默认选项构建时,分析内核根本不会在硬件上运行
如果我为sm_30构建此代码,并在具有2gb内存(计算能力3.0)的GTX 670上运行它,我会得到以下结果:
~/cbow/word2vec_cbow$ make
nvcc word2vec.cu -o word2vec -O3 -Xcompiler -march=native -w -Xptxas="-v" -arch=sm_30 -lineinfo
ptxas info : 0 bytes gmem
ptxas info : Compiling entry function '_Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_' for 'sm_30'
ptxas info : Function properties for _Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 34 registers, 448 bytes cmem[0], 12 bytes cmem[2]
~/cbow/word2vec_cbow$ ./word2vec -train text8 -output vectors.bin -cbow 1 -size 200 -window 7 -negative 1 -hs 1 -sample 1e-3 -threads 1 -binary 1 -save-vocab voc #> out 2>&1
Starting training using file text8
Vocab size: 71290
Words in train file: 16718843
vocab size = 71290
Alpha: 0.000009 Progress: 100.00% Words/thread/sec: 1217.45k
ie.代码正确运行到完成,没有任何错误。我无法告诉您为什么无法在硬件上运行代码,因为我无法在我的硬件上重现您的错误。您需要自己进行一些调试,以找到根本原因。抱歉,这是GeForce GT 750MB。顺便说一句,应该这样做:-arch=compute_30-code=sm_30,检查出来我很确定这与问题无关你试过用cuda memcheck运行代码吗?好的,所以用cuda memcheck运行代码会显示很多非法访问错误。是否仍然可以访问行号?它显示指令地址,但不显示行号。但是,我仍然不知道ear为什么它在一个编译选项下运行良好,但在另一个编译选项下无法启动。请解释您可以使用
-lineinfo
选项构建代码,让cuda memcheck报告行号。我不能不看代码就解释,找到代码是您的工作。对不起,我不会为您分析1000多行代码。我是100%certain您关于代码在为sm_35编译时运行的断言是完全错误的,并且当您为compute capability 3.5构建代码时,没有内核会运行。
~/cbow/word2vec_cbow$ make
nvcc word2vec.cu -o word2vec -O3 -Xcompiler -march=native -w -Xptxas="-v" -arch=sm_35 -lineinfo
ptxas info : 0 bytes gmem
ptxas info : Compiling entry function '_Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_' for 'sm_35'
ptxas info : Function properties for _Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 34 registers, 448 bytes cmem[0], 8 bytes cmem[2]
~/cbow/word2vec_cbow$ ./word2vec -train text8 -output vectors.bin -cbow 1 -size 200 -window 7 -negative 1 -hs 1 -sample 1e-3 -threads 1 -binary 1 -save-vocab voc #> out 2>&1
Starting training using file text8
Vocab size: 71290
Words in train file: 16718843
vocab size = 71290
cbow.cu 114 : invalid device function
~/cbow/word2vec_cbow$ make
nvcc word2vec.cu -o word2vec -O3 -Xcompiler -march=native -w -Xptxas="-v" -arch=sm_30 -lineinfo
ptxas info : 0 bytes gmem
ptxas info : Compiling entry function '_Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_' for 'sm_30'
ptxas info : Function properties for _Z11cbow_kernelILx1EEvllflPKilPVfS3_PKfS1_PKcS1_S1_llS3_
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 34 registers, 448 bytes cmem[0], 12 bytes cmem[2]
~/cbow/word2vec_cbow$ ./word2vec -train text8 -output vectors.bin -cbow 1 -size 200 -window 7 -negative 1 -hs 1 -sample 1e-3 -threads 1 -binary 1 -save-vocab voc #> out 2>&1
Starting training using file text8
Vocab size: 71290
Words in train file: 16718843
vocab size = 71290
Alpha: 0.000009 Progress: 100.00% Words/thread/sec: 1217.45k