Can Video calssification using deeplearning run on GPU ?

2 visualizaciones (últimos 30 días)
Xie Shipley
Xie Shipley el 17 de Nov. de 2023
Comentada: Xie Shipley el 18 de Nov. de 2023
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

Respuesta aceptada

Drew
Drew el 17 de Nov. de 2023
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 comentario
Xie Shipley
Xie Shipley el 18 de Nov. de 2023
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)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by