I'm looking at the Matlab example on rendering Fractals with GPUs ( https://www.mathworks.com/help/distcomp/examples/illustrating-three-approaches-to-gpu-computing-the-mandelbrot-set.html ) and it works fine. But I want to loop this, and I get this error:
Error using gpuArray.linspace
An unexpected error occurred trying to launch a kernel. The CUDA
error was:
invalid configuration argument
Error in matlabArrFunLoop (line 11)
x = gpuArray.linspace( xlim(1)/k, xlim(2)/k, gridSize );
What's wrong with looping this code? Thanks
Code:
clear
close all
gridSize = 3000;
xlim = [-0.748766713922161, -0.748766707771757];
ylim = [ 0.123640844894862, 0.123640851045266];
for k=1:1:3
% Setup
tic
k
x = gpuArray.linspace( xlim(1)/k, xlim(2)/k, gridSize );
y = gpuArray.linspace( ylim(1)/k, ylim(2)/k, gridSize );
[xGrid,yGrid] = meshgrid( x, y );
% Calculate
count = arrayfun( @iterFunc,xGrid, yGrid );
% Show
count = gather( count ); % Fetch the data back from the GPU
figure(3)
imagesc( x, y, count )
axis off
toc
end
function count = iterFunc(x0,y0)
maxIterations=5000;
z0 = complex(x0,y0);
z = z0;
count = 1;
while (count <= maxIterations) && (abs(z) <= 2)
count = count + 1;
z = z*z + z0;
end
count = log(count);
end

1 Kommentar

I get that message, but first I get
Error using gpuArray/arrayfun
The GPU has timed out. See www.mathworks.com/gputimeout for details about GPU timeouts and how to avoid them.
I have some other things going on with my computer at the moment which might be trying to use some of the GPU cycles. But just in general, gpu can time out if the work it is asked to do takes longer then the kernel hold time that is imposed for GPUs that are not in exclusive mode.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt J
Matt J am 22 Dez. 2017

0 Stimmen

The code runs fine for me. Try restarting MATLAB and/or the computer.

10 Kommentare

MR
MR am 22 Dez. 2017
Did you run it multiple times?
Matt J
Matt J am 22 Dez. 2017
Bearbeitet: Matt J am 22 Dez. 2017
About 5 or 6 times. How many times was I supposed to run it?
MR
MR am 22 Dez. 2017
Bearbeitet: MR am 22 Dez. 2017
I get it the first time. What gpu do you have? I have a 1080 ti.
Name: 'GeForce GTX 1080 Ti'
Index: 1
ComputeCapability: '6.1'
SupportsDouble: 1
DriverVersion: 8
ToolkitVersion: 8
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.1811e+10
AvailableMemory: 9.7107e+09
MultiprocessorCount: 28
ClockRateKHz: 1582000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
Walter Roberson
Walter Roberson am 22 Dez. 2017
I do not get this the first time on my 650M: I get a response that the GPU has timed out. When you have a GPU device that is shared between graphics and compute usage, then kernels typically have a fairly limited timeout.
The information I find suggests that the GeForce GTX 1080 Ti does not support TCC.
MR
MR am 22 Dez. 2017
As I have a very powerful card, I don't seem to get the timeout. However, when I loop large matrices, I get
Error using gpuArray.linspace
An unexpected error occurred trying to launch a kernel. The CUDA
error was:
invalid configuration argument
For example, I can run my algorithm (not the one posted) with 1080p frames to the end, but if I run the same algorithm with 4k frames, I invariably get this error at the 191th frame...
Matt J
Matt J am 22 Dez. 2017
I have a Titan X, but I've disabled the timeout.
Joss Knight
Joss Knight am 22 Dez. 2017
Timeouts can have some very odd side-effects. When I have timeouts enabled I get a launch failure issue with your code. But when I disable timeouts, I get no problems. So I recommend you try that first. The simplest way is to create a new DWORD registry key called TdrLevel in the appropriate place and set to 0, following the instructions on this page:
Then reboot and try again.
MR
MR am 22 Dez. 2017
It solved the issue. Thanks!
Hoang Nguyen
Hoang Nguyen am 8 Jan. 2018
Hello Joss, is there any problem if we disable timeouts by your suggestion. In fact, I could run any examples utilizing GPU but not so sure about consequences since that registry key is not built-in.
Joss Knight
Joss Knight am 16 Jan. 2018
There is potential for system lock-up if you are using perhaps less rigorous GPU code that may contain bugs. If the graphics card can't draw graphics because it's locked up running some CUDA kernel then to all intents and purposes your system has crashed.
But this is very rarely an issue for most people.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with GPU Coder finden Sie in Hilfe-Center und File Exchange

Gefragt:

MR
am 21 Dez. 2017

Kommentiert:

am 16 Jan. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by