Can Video calssification using deeplearning run on GPU ?

조회 수: 2 (최근 30일)
Xie Shipley
Xie Shipley 2023년 11월 17일
댓글: Xie Shipley 2023년 11월 18일
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