Can Video calssification using deeplearning run on GPU ?

1 次查看(过去 30 天)
If there are someone can tell me can this Video Classification example in MATLAB doc run on GPU ?
inputSize = [28 28 1];
filterSize = 5;
numFilters = 20;
numHiddenUnits = 200;
numClasses = 10;
layers = [ ...
sequenceInputLayer(inputSize,'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(filterSize,numFilters,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','last','Name','lstm')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
I Got this error :
CUDNN_STAT​US_EXECUTI​ON_FAILED
You can click here to see more error detail

采纳的回答

Drew
Drew 2023-11-17
Using the MATLAB AI Chat Playground https://www.mathworks.com/matlabcentral/playground/new (see announcement at https://blogs.mathworks.com/community/2023/11/07/the-matlab-ai-chat-playground-has-launched/), I asked your question, and the response was:
Yes, you can train and test this LSTM network on a GPU in MATLAB. To do so, you can use the "trainNetwork" function with the "ExecutionEnvironment" option set to "gpu". Here's an example:
% Define the LSTM network
inputSize = [28 28 1];
filterSize = 5;
numFilters = 20;
numHiddenUnits = 200;
numClasses = 10;
layers = [ ...
sequenceInputLayer(inputSize,'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(filterSize,numFilters,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','last','Name','lstm')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
% Specify the training options
options = trainingOptions('adam', ...
'MaxEpochs', 10, ...
'MiniBatchSize', 128, ...
'Shuffle', 'every-epoch', ...
'Verbose', false, ...
'Plots', 'training-progress', ...
'ExecutionEnvironment', 'gpu');
% Train the network
net = trainNetwork(XTrain,YTrain,layers,options);
% Test the network
YPred = classify(net,XTest);
accuracy = sum(YPred == YTest)/numel(YTest);
In this example, the "ExecutionEnvironment" option is set to "gpu" in the "trainingOptions" function. This will automatically use the GPU for training and testing the network, if one is available.
How can I check if my GPU is compatible with MATLAB?
Can I use multiple GPUs to train my network in MATLAB?
Is it possible to switch between CPU and GPU during training in MATLAB?
Here is the image view of the AI response:
If this answer helps you, please accept the answer, and I recommend to try the MATLAB AI Chat Playground https://www.mathworks.com/matlabcentral/playground/new for your MATLAB questions.
  1 个评论
Xie Shipley
Xie Shipley 2023-11-18
Do you have some information about XTrain and YTrain,? I want to check returned data format of my custom data store(mine is 791x2 table, two columns are predictors and responses, predictors is 700 cell contain 64x64x1x8000 image sequence , 8000 is the number of time steps response is 700 cell contain labels 1x8000)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by