[英]What is the meaning of CUFFT_ALLOC_FAILED return value when calling cufftGetSize*()?
[英]CUFFT_ALLOC_FAILED Error in nsight eclipse
我編寫了一個簡單的cuda文件,該文件已成功在Visual Studio 2010和nsight eclipse中構建
代碼在這里
#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);
}
例如,我四次更改了NX&BATCH
const int NX = 1024;
const int BATCH = 90000;
const int SIGNAL_SIZE = NX * BATCH;
cufftHandle plan;
cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
我在Visual Studio 2010和2012(Windows 7 64位)中成功運行了Sample,但是在ubuntu 12.04(32位)中,nsight eclipse給出了此錯誤
CUFFT_ALLOC_FAILED
用於cufftPlan1d函數
我將BATCH更改為80000(NX = 1024),並且在ubuntu中發生了此錯誤,但是在Visual Studio 2010中我沒有任何錯誤地運行!
我使用具有此功能的Cuda工具包5.5:
單精度轉換大小高達1.28億個元素
和80000 * 1024 = 81920000個元素<1.28億個元素
我將BATCH更改為8000(NX = 1024),並且在ubuntu中未發生該錯誤
請幫我
謝謝
您可以使用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文檔: http : //docs.nvidia.com/cuda/cufft/#function-cufftplan1d
CUFFT_ALLOC_FAILED : The allocation of GPU resources for the plan failed.
意味着cufftPlan1d()
無法在GPU上分配內存,可能是因為沒有足夠的可用內存。 可用的VRAM在各個操作系統之間不會發生變化,因此您可能沒有合適的驅動程序來驅動卡,或者您正在另一台具有有限VRAM的GPU的計算機上運行Ubuntu。 您可以使用cudaGetDeviceProperties()
檢查可用的全局內存
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.