problems with @arrayfun on GPU
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
christian Velasquez Javier
am 2 Aug. 2022
Beantwortet: Joss Knight
am 8 Aug. 2022
Hi,
I am starting to using the arrafun function with GPU capabilities (I have an NVIDIA GeForce GTX 1650 with Max-Q Design).
I am following jsut the example from matlab website
R1 = rand(2,5,4,"gpuArray");
R2 = rand(2,1,4,3,"gpuArray");
R3 = rand(1,5,4,3,"gpuArray");
R = arrayfun(@(x,y,z)(x+y.*z),R1,R2,R3);
The code above runs perfectly in the Command Window, but if I want to run this from an script or live-script I get the following error:
Index exceeds the number of array elements. Index must not exceed 0.
Some hint what is happening?
Akzeptierte Antwort
Joss Knight
am 8 Aug. 2022
This is a bug. I have reported it. Thanks for finding it!
In the meantime, you can work around the issue by using a local function rather than an anonymous function.
R1 = rand(2,5,4,"gpuArray");
R2 = rand(2,1,4,3,"gpuArray");
R3 = rand(1,5,4,3,"gpuArray");
R = arrayfun(@iFunc,R1,R2,R3);
function w = iFunc(x,y,z)
w = x+y.*z;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Find more on GPU Computing 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!