Strange phenomenon when running FFT on GP
1 view (last 30 days)
Show older comments
Parallel Computing Toolbox 7.4
MatlabR2021a
GPU Memory 5GB
I ran the following code.
clear
Nx = 1281;
Ny = 340;
Nz = 340;
A = gpuArray(single(rand(Nx, 1)));
B = single(rand(Nx, Ny, Nz));
C = gpuArray(single(rand(Nx, 1)) + i*single(rand(Nx, 1)));
% ↓ The 9th line ↓
answer = A .* B - real(ifftn(C .* gpuArray(B)));
Then, the first time on line 9, the following error occurs: "An invalid FFT plan was used on the GPU."
Next, I execute only the 9th line as, it was executed normally without any error.
Between the first and second time, GPU memory is not consumed by anything outside. I will get the same result no matter how many times you try
I have no idea what's going on.
Can you explain what is happening? thank you.
0 Comments
Answers (1)
Walter Roberson
on 22 Nov 2021
"CUFFT provides a simple configuration mechanism called a plan that pre-configures internal building blocks such that the execution time of the transform is as fast as possible for the given configuration and the particular GPU hardware selected. Then, when the execution function is called, the actual transform takes place following the plan of execution. The advantage of this approach is that once the user creates a plan, the library retains whatever state is needed to execute the plan multiple times without recalculation of the configuration."
So that is what an FFT plan is .
Why does it complain about invalid FFT plan? Why does it work afterwards?
Over in https://www.mathworks.com/matlabcentral/answers/786066-fftn-on-gpu-array#comment_1424841 we see a hint that maybe you ran out of GPU memory. The comment I link to shows some software to help keep track of GPU variables.
See Also
Categories
Find more on GPU Computing in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!