Error using gpuArray/arrayfun ... Use of functional workspace is not supported.
15 ビュー (過去 30 日間)
古いコメントを表示
I define a simple function of summation.m as follows:
--------------------------------------------
function out = summation(a, b, c, d)
out = a+b+c+d;
--------------------------------------------
Then, I run the following code:
--------------------------------------------
R1 = gpuArray.rand(10,10);
R2 = gpuArray.rand(10,10);
R3 = gpuArray.rand(10,10);
f = @(a,b,c)summation( a, b, c, 5);
R = arrayfun(f,R1,R2,R3);
--------------------------------------------
This works fine. However, if I change the function handle as
--------------------------------------------
R1 = gpuArray.rand(10,10);
R2 = gpuArray.rand(10,10);
R3 = gpuArray.rand(10,10);
*_d = 5;_*
f = @(a,b,c)summation( a, b, c, *_d_* );
R = arrayfun(f,R1,R2,R3);
--------------------------------------------
I get the error message "Error using gpuArray/arrayfun Use of functional workspace is not supported." Is there a way to resolve this issue? I would like to resolve this so that I can use GPU in the case that d is either a vector or a matrix.
0 件のコメント
回答 (1 件)
Jill Reese
2013 年 12 月 30 日
As of the latest MATLAB release (R2013b) arrayfun on the GPU does not support anonymous functions that have been created using variables from the existing MATLAB workspace. This is the meaning of the error message you have encountered.
Unless I am missing something, you should not need to create your function handle using your variable, d. Arrayfun on the GPU supports scalar expansion so d can be a scalar, a vector, or a matrix as long as its dimensions are either the same as your R1, R2, and R3 variables or the dimension is 1. So for the dimensions you mention above, d can be passed into the arrayfun call in the same way as R1, R2, and R3 and the call will succeed if d has size 1 x 1, 10 x 1, 1 x 10, or 10 x 10. Does this not work for you?
1 件のコメント
LASIN T
2022 年 8 月 10 日
I made everything same length and I am still getting the same error, "Use of functional workspace is not supported."
参考
カテゴリ
Help Center および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!