C++ nsight eclipse中的CUFFT_ALLOC_失败错误
我编写了一个简单的cuda文件,它成功地在VisualStudio2010和nsight eclipse中构建 代码在这里C++ nsight eclipse中的CUFFT_ALLOC_失败错误,c++,eclipse,cuda,gpu,C++,Eclipse,Cuda,Gpu,我编写了一个简单的cuda文件,它成功地在VisualStudio2010和nsight eclipse中构建 代码在这里 #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cufft.h> #include <cutil_inline.h> typedef float2 Complex; in
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cufft.h>
#include <cutil_inline.h>
typedef float2 Complex;
int main(int argc, char** argv)
{
const int NX = 1024;
const int BATCH = 90000;
const int SIGNAL_SIZE = NX * BATCH;
Complex* h_signal = (Complex*)malloc(sizeof(Complex) * SIGNAL_SIZE);
for (unsigned int i = 0; i < SIGNAL_SIZE; ++i) {
h_signal[i].x = rand() / (float)RAND_MAX;
h_signal[i].y = 0;
}
Complex* d_signal;
cutilSafeCall(cudaMalloc((void**)&d_signal, sizeof(Complex)*SIGNAL_SIZE));
cutilSafeCall(cudaMemcpy(d_signal, h_signal, sizeof(Complex)*SIGNAL_SIZE,
cudaMemcpyHostToDevice));
cufftHandle plan;
cufftSafeCall(cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH));
cufftSafeCall(cufftExecC2C(plan, (cufftComplex *)d_signal, (cufftComplex *)d_signal, CUFFT_FORWARD));
cutilSafeCall(cudaMemcpy(h_signal, d_signal, SIGNAL_SIZE*sizeof(Complex),
cudaMemcpyDeviceToHost));
//Destroy CUFFT context
cufftSafeCall(cufftDestroy(plan));
// cleanup memory
free(h_signal);
cutilSafeCall(cudaFree(d_signal));
cudaThreadExit();
cutilExit(argc, argv);
}
我在VisualStudio2010和2012(Windows7 64位)中成功运行了示例,但在ubuntu中运行了示例
12.04(32位)nsight eclipse给出此错误
CUFFT_ALLOC_失败
对于cufftPlan1d函数
我将批处理更改为80000(NX=1024)&这个错误发生在ubuntu中
但在VisualStudio2010中,我运行时没有任何错误
我使用的Cuda toolkit 5.5具有以下功能:
单精度变换大小高达1.28亿个元素
80000*1024=81920000个元素<1.28亿个元素
我将批处理更改为8000(NX=1024)&这个错误在ubuntu中没有发生
请帮帮我
感谢CUFFT文档:
CUFFT\u ALLOC\u失败:为计划分配GPU资源失败。
意思是cufftPlan1d()
无法在GPU上分配内存,可能是因为没有足够的可用内存。可用的VRAM不会在不同的操作系统之间发生变化,因此,要么您的卡没有合适的驱动程序,要么您在另一台带有GPU的机器上运行Ubuntu,而GPU限制了VRAM。您可以使用cudaGetDeviceProperties()检查可用的全局内存。Cuft文档:
CUFFT\u ALLOC\u失败:为计划分配GPU资源失败。
意思是
cufftPlan1d()
无法在GPU上分配内存,可能是因为没有足够的可用内存。可用的VRAM不会在不同的操作系统之间发生变化,因此,要么您的卡没有合适的驱动程序,要么您在另一台带有GPU的机器上运行Ubuntu,而GPU限制了VRAM。您可以使用cudaGetDeviceProperties()检查可用的全局内存您可以使用cufftEstimate1d
估计cuFFT调用所需的内存量
#include <conio.h>
#include <cufft.h>
#define cufftSafeCall(err) __cufftSafeCall(err, __FILE__, __LINE__)
inline void __cufftSafeCall(cufftResult err, const char *file, const int line)
{
if( CUFFT_SUCCESS != err) {
fprintf(stderr, "cufftSafeCall() CUFFT error in file <%s>, line %i.\n",
file, line);
getch(); exit(-1);
}
}
int main() {
const int NX = 1024;
const int BATCH = 100000;
size_t workSize;
cufftSafeCall(cufftEstimate1d(NX, CUFFT_C2C, BATCH, &workSize));
printf("%i\n",workSize);
getchar();
}
#包括
#包括
#定义cufftSafeCall(err)\ cufftSafeCall(err、\文件、\行)
内联void\uuu cufftSafeCall(cufftResult err、const char*文件、const int行)
{
如果(成功!=错误){
fprintf(stderr,“cufftSafeCall()文件中的CUFFT错误,第%i行。\n”,
文件、行);
getch();退出(-1);
}
}
int main(){
常数int NX=1024;
常数int批=100000;
尺寸/工作尺寸;
cufftSafeCall(cufftEstimate1d(NX、CUFFT_C2C、批次和工作尺寸));
printf(“%i\n”,工作大小);
getchar();
}
您可以使用cufftEstimate1d
估计cuFFT通话所需的内存量
#include <conio.h>
#include <cufft.h>
#define cufftSafeCall(err) __cufftSafeCall(err, __FILE__, __LINE__)
inline void __cufftSafeCall(cufftResult err, const char *file, const int line)
{
if( CUFFT_SUCCESS != err) {
fprintf(stderr, "cufftSafeCall() CUFFT error in file <%s>, line %i.\n",
file, line);
getch(); exit(-1);
}
}
int main() {
const int NX = 1024;
const int BATCH = 100000;
size_t workSize;
cufftSafeCall(cufftEstimate1d(NX, CUFFT_C2C, BATCH, &workSize));
printf("%i\n",workSize);
getchar();
}
#包括
#包括
#定义cufftSafeCall(err)\ cufftSafeCall(err、\文件、\行)
内联void\uuu cufftSafeCall(cufftResult err、const char*文件、const int行)
{
如果(成功!=错误){
fprintf(stderr,“cufftSafeCall()文件中的CUFFT错误,第%i行。\n”,
文件、行);
getch();退出(-1);
}
}
int main(){
常数int NX=1024;
常数int批=100000;
尺寸/工作尺寸;
cufftSafeCall(cufftEstimate1d(NX、CUFFT_C2C、批次和工作尺寸));
printf(“%i\n”,工作大小);
getchar();
}
何时何地发生错误?请注意,cudaThreadExit()
已被弃用,取而代之的是cudaDeviceReset()
,请参阅我有一个GTX 650 Ti boost,它有2 GB RAM。当我设置Nx=1024&Batch=90000时,我在同一台机器上构建和运行示例(首先在Windows7和VisualStudio2010中,然后在ubuntu 12.04中)。eclipse有一个CUFFT_ALLOC_失败错误,但在VisualStudio中我运行它时没有任何错误!错误发生在何时何地?请注意,cudaThreadExit()
已被弃用,取而代之的是cudaDeviceReset()
,请参阅我有一个GTX 650 Ti boost,它有2 GB RAM。当我设置Nx=1024&Batch=90000时,我在同一台机器上构建和运行示例(首先在Windows7和VisualStudio2010中,然后在ubuntu 12.04中)。eclipse有一个CUFFT_ALLOC_失败错误,但在VisualStudio中我运行它时没有任何错误!我用的是同一台机器。我认为驱动程序没有问题,因为所有cuda示例都成功构建和运行!我认为gpu分配在32位和64位上有所不同。这是真的吗?我使用的是同一台机器。我认为驱动程序没有问题,因为所有cuda示例都成功构建和运行!我认为gpu分配在32位和64位上有所不同,这是真的吗?