Error when using 'useGPU' for training neural networks
8 次查看(过去 30 天)
显示 更早的评论
I am receiving an error whenever I try to perform patternnet training with the 'useGPU' option. I am using MATLAB R2016a under Windows 7 SP1. The error also occurs in MATLAB R2015a under Windows 7 SP1. I have the latest NVIDIA CUDA toolkit installed (version 7.5). I also have the latest NVIDIA drivers installed for my GTX 780.
Whenever I run:
net=patternnet([10,10]);
net.trainFcn='trainlm';
net.layers{3}.transferFcn='softmax';
[net,tr]=train(net,x1',d1','useGPU','yes');
MATLAB defaults to using 'trainscg' for the default training method. The training is successfully performed using the GPU. Whenever I run:
net=patternnet([10,10]);
net.trainFcn='trainscg';
net.layers{3}.transferFcn='softmax';
[net,tr]=train(net,x1',d1','useGPU','yes');
MATLAB reports that there is an error using gpuArray/arrayfun:
Error using gpuArray/arrayfun
Variable 't' changed type. Consider renaming variable on left hand side of assignment.
For more information see Tips and Restrictions.
Error in 'netHints' (line: 666)
Error in nnGPUOp.bg (line 133)
[perfs1,perfs2,perfs3,N1,N2,N3,dy] =
arrayfun(hints.performFcns.perf_dy_3masks,ti,yi,en,ew,mask1,mask2,mask3,S);
Error in nnGPUOp.perfsGrad (line 5)
[gWB,Perfs,PerfN] = nnGPUOp.bg...
Error in nnCalcLib/perfsGrad (line 294)
lib.calcMode.perfsGrad(calcNet,lib.calcData,lib.calcHints);
Error in trainscg>initializeTraining (line 153)
[worker.perf,worker.vperf,worker.tperf,worker.gWB,worker.gradient] = calcLib.perfsGrad(calcNet);
Error in nnet.train.trainNetwork>trainNetworkInMainThread (line 28)
worker = localFcns.initializeTraining(archNet,calcLib,calcNet,tr);
Error in nnet.train.trainNetwork (line 16)
[archNet,tr] = trainNetworkInMainThread(archNet,rawData,calcLib,calcNet,tr,feedback,localFcns);
Error in trainscg>train_network (line 147)
[archNet,tr] = nnet.train.trainNetwork(archNet,rawData,calcLib,calcNet,tr,localfunctions);
Error in trainscg (line 59)
[out1,out2] = train_network(varargin{2:end});
Error in network/train (line 369)
[net,tr] = feval(trainFcn,'apply',net,data,calcLib,calcNet,tr);
If trainFnc is set to anything other than 'trainlm', such as 'trainbfg', I receive the same error.
Oddly enough, I don't encounter this error when training a feedforwardnet. I was able to succesfully use 'trainbfg', for example, without any issues. My sense is that there might be some toolbox coding issue for patternnets.
0 个评论
回答(1 个)
Amanjit Dulai
2016-4-25
I suspect that the problem here is related to the type for the variable d1. I managed to replicate your error by using a single precision array for d1. Try casting it to double precision.
1 个评论
HyeongHun LEE
2017-10-25
编辑:HyeongHun LEE
2017-10-25
I had a similar problem with this issue(for loop statement of gpu used-autoencoder), and solved with changed the array variable type(from single to double)in gpuarray. Thank you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!