Can Video calssification using deeplearning run on GPU ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Xie Shipley
el 17 de Nov. de 2023
Comentada: Xie Shipley
el 18 de Nov. de 2023
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_STATUS_EXECUTION_FAILED
You can click here to see more error detail
0 comentarios
Respuesta aceptada
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!