A working example of Neural Network "train" with GPU and inputs / targets as SINGLE matrices
1 view (last 30 days)
Show older comments
Hi guys,
I'm starting to employ my CUDA GPU with the Neural Network toolbox, but if I feed the trainer with double matrices I soon run out of CUDA memory. As a solution to improve both computational efficiency and data size limit, I've thought about employing single matrices. The problem is that I always get this error, and I would like to kindly ask you for a working example of GPU training with single matrices. Thanks in advance!
Error using gpuArray/arrayfun
Variable 'y' changed type. Consider renaming variable on left hand side of assignment.
For more information see Tips and Restrictions.
Error in 'netHints' (line: 667)
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 155)
[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 149)
[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);
Error in test (line 52)
net2 = train(net2,inputs_g,targets_g,'useGpu','yes'); % Execute on GPU with NNET formatted
gpuArrays
1 Comment
Cameron Lee
on 31 Jan 2020
I'm not sure if this issue is stil persisting for you, but I also have the same problem. I've started another thread (here: https://www.mathworks.com/matlabcentral/answers/500655-training-nn-with-single-precision-data-on-gpu?s_tid=prof_contriblnk) that has gotten the attention of a Mathworks staff memeber. Perhaps he will be able to help.
I've seen others with this issue as well, and even one that had an answer bascially saying to use double-precision to get around the problem. However, for large datasets, single-precision data processed on most GPUs would likely be exponentially faster, so while it is a work-around for the issue, it doesn't seem to me to be the ideal solution. So - we'll see!
Answers (1)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!