I’m trying to calculate the correlation between two sets of random data using the GPU in MATLAB R2018b. Here’s my code:
x = randn(30,4);
y = randn(30,4);
x = gpuArray(x);
y = gpuArray(y);
corr(x, y)
However, I encounter the following error:
Error using gpuArray/vecnorm (line 24)
Too many input arguments.
Error in corr>corrPearson (line 305)
dx = vecnorm(x,2,1);
Error in corr (line 212)
coef = corrFun(rows,tail,x,y);
I’ve checked the vecnorm function using which vecnorm -all
, and here are the results:
built-in (/usr/local/MATLAB/R2018b/toolbox/matlab/matfun/vecnorm)
built-in (/usr/local/MATLAB/R2018b/toolbox/matlab/matfun/vecnorm) % connector.internal.LoggerLevel method
/usr/local/MATLAB/R2018b/toolbox/distcomp/gpu/@gpuArray/vecnorm.m % gpuArray method
/usr/local/MATLAB/R2018b/toolbox/matlab/bigdata/@tall/vecnorm.m % tall method
/usr/local/MATLAB/R2018b/toolbox/distcomp/parallel/@codistributed/vecnorm.m % codistributed method
I was expecting to use the corr function with gpuArray inputs to compute the correlation matrix on the GPU.
New contributor
Ethan Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.