Custom Neural Network Sample Code Fails on GPU

2 次查看(过去 30 天)
Runs on CPU but fails on GPU.
The extra steps I added which are required to run efficiently on GPU
xg = nndata2gpu(X);
yg = nndata2gpu(Y);
and then either net = configure(net,X,T); OR using the [Xs,Xi,Ai,Ys,EWs,shift] = preparets(net,X,Y); method and sending all of the results to the gpu.
The problem appears to be when there are multiple input vectors of differing lengths. I have confirmed that this fails on simpler examples of similar type.
If there's no workaround this appears to be an issue preventing multiple input recurrent networks from running on the gpu. (I can try hacking a solution where every entry is a separate input vector, but this increases complexity and possibly might not work in all situations)
The Exception is: Dimensions of matrices being concatenated are not consistent.
Trace:
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 75)
m{n} = cat(2,c{n,:});
Error in nnGPU.pc (line 52)
xoffset = cell2mat(xoffset');
Error in nncalc.preCalcData>iPreCalcDataForNNDATA2GPU (line 43)
data.Pc = mode.pc(net,data.X,data.Xi,data.Q,data.TS,hints);
Error in nncalc.preCalcData (line 7)
data = iPreCalcDataForNNDATA2GPU(net,data,doPc);
Error in nncalc.setup1>setupImpl (line 176)
calcData = nncalc.preCalcData(matlabMode,matlabHints,net,data,doPc,doPd,calcHints.doFlattenTime);
Error in nncalc.setup1 (line 16)
[calcMode,calcNet,calcData,calcHints,net,resourceText] = setupImpl(calcMode,net,data);
Error in nncalc.setup (line 7)
[calcMode,calcNet,calcData,calcHints,net,resourceText] = nncalc.setup1(calcMode,net,data);
Error in network/train (line 357)
[calcLib,calcNet,net,resourceText] = nncalc.setup(calcMode,net,data);

回答(1 个)

Amanjit Dulai
Amanjit Dulai 2017-9-8
Instead of using nndata2gpu to prepare your data for GPU training, you can use the 'useGPU' flag. Just change the call to train in the example to the following:
net = train(net,X,T, 'useGPU', 'yes');
  1 个评论
Zachary David
Zachary David 2017-9-12
编辑:Zachary David 2017-9-12
Thanks Amanjit, however the size of the data sets (200 sequences of 7000 entries) I'm using in practice prohibit this method from being practical. In fact, using a batch size of 1 with a sequence length of 7000 never completes.
(this is on a Titan Xp with "computation only" CUDA settings enabled.)

请先登录,再进行评论。

类别

Help CenterFile 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!

Translated by