简体   繁体   English

CUFFT_ALLOC_FAILED nsight eclipse中的错误

[英]CUFFT_ALLOC_FAILED Error in nsight eclipse

I wrote a simple cuda file that successfully build in visual studio 2010 & nsight eclipse 我编写了一个简单的cuda文件,该文件已成功在Visual Studio 2010和nsight eclipse中构建

the code is here 代码在这里

#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);
}

I changed NX & BATCH four times for example with 例如,我四次更改了NX&BATCH

const int NX = 1024;

const int BATCH = 90000;

const int SIGNAL_SIZE = NX * BATCH;

cufftHandle plan;
cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);

I successfully run Sample in visual studio 2010 & 2012 (windows 7 64 bit) but in ubuntu 12.04 (32 bit) nsight eclipse give this Error 我在Visual Studio 2010和2012(Windows 7 64位)中成功运行了Sample,但是在ubuntu 12.04(32位)中,nsight eclipse给出了此错误

CUFFT_ALLOC_FAILED CUFFT_ALLOC_FAILED

for cufftPlan1d function 用于cufftPlan1d函数

I change BATCH to 80000 (NX = 1024) & this error occurred in ubuntu but in visual studio 2010 i run without any errors! 我将BATCH更改为80000(NX = 1024),并且在ubuntu中发生了此错误,但是在Visual Studio 2010中我没有任何错误地运行!

I use Cuda toolkit 5.5 that has this feature: 我使用具有此功能的Cuda工具包5.5:

Transform sizes up to 128 million elements in single precision 单精度转换大小高达1.28亿个元素

and 80000 * 1024 = 81920000 elements < 128 million elements 和80000 * 1024 = 81920000个元素<1.28亿个元素

I change BATCH to 8000 (NX = 1024) & that error does not occured in ubuntu 我将BATCH更改为8000(NX = 1024),并且在ubuntu中未发生该错误

Please Help Me 请帮我

thanks 谢谢

You can estimate the amount of memory required by your cuFFT call using cufftEstimate1d . 您可以使用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();

} 

CUFFT Documentation: http://docs.nvidia.com/cuda/cufft/#function-cufftplan1d CUFFT文档: http : //docs.nvidia.com/cuda/cufft/#function-cufftplan1d

CUFFT_ALLOC_FAILED : The allocation of GPU resources for the plan failed.

Meaning cufftPlan1d() was not able to allocate memory on the GPU, likely because there is not enough free memory. 意味着cufftPlan1d()无法在GPU上分配内存,可能是因为没有足够的可用内存。 The available VRAM would not have changed between operating systems, so either you don't have the right drivers for your card or you're running Ubuntu on a separate machine with a GPU that has limited VRAM. 可用的VRAM在各个操作系统之间不会发生变化,因此您可能没有合适的驱动程序来驱动卡,或者您正在另一台具有有限VRAM的GPU的计算机上运行Ubuntu。 You can check the available global memory with cudaGetDeviceProperties() 您可以使用cudaGetDeviceProperties()检查可用的全局内存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM