the utilization of cpu and gpu is low, how to increase them?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
while i am using matlab to train a alexnet from the scratch on window, the utilization ratio of cpu and gpu of my computer is low, and I wonder how to increase them.
here is my code:
trainImagesetPath = 'E:\deep_learning_dataset\tiny-imagenet-200\train';
valImagesetPath = 'E:\deep_learning_dataset\tiny-imagenet-200\val';
testImagesetPath = 'E:\deep_learning_dataset\tiny-imagenet-200\test';
miniBatchSize = 960;
imdsTrain = imageDatastore(trainImagesetPath, 'IncludeSubfolders', true, ...
'LabelSource', 'foldernames', 'FileExtensions',{'.jpg','.JPG', '.JPEG'}, 'ReadSize', miniBatchSize);
imdsValidation = imageDatastore(valImagesetPath, 'IncludeSubfolders', true, ...
'LabelSource', 'foldernames', 'FileExtensions',{'.jpg','.JPG', '.JPEG'}, 'ReadSize', miniBatchSize);
imdsTest = imageDatastore(testImagesetPath, 'IncludeSubfolders', true);
layers = [imageInputLayer([224 224 3])
convolution2dLayer(11, 96, 'Stride', [4, 4], 'Padding', [0 0 0 0])
reluLayer
batchNormalizationLayer
maxPooling2dLayer(3, 'Stride', [2, 2], 'Padding', [0 0 0 0])
groupedConvolution2dLayer(5, 128, 2, 'Stride', [1, 1], 'Padding', [2 2 2 2])
reluLayer
batchNormalizationLayer
maxPooling2dLayer(3, 'Stride', [2, 2], 'Padding', [0 0 0 0])
convolution2dLayer(3, 384, 'Stride', [1, 1], 'Padding', [1 1 1 1])
reluLayer
groupedConvolution2dLayer(3, 192, 2, 'Stride', [1, 1], 'Padding', [1 1 1 1])
reluLayer
groupedConvolution2dLayer(3, 128, 2, 'Stride', [1, 1], 'Padding', [1 1 1 1])
reluLayer
maxPooling2dLayer(3, 'Stride', [2, 2], 'Padding', [0 0 0 0])
fullyConnectedLayer(4096)
reluLayer
dropoutLayer(0.5)
fullyConnectedLayer(4096)
reluLayer
dropoutLayer(0.5)
fullyConnectedLayer(200)
softmaxLayer
classificationLayer
];
% analyzeNetwork(layers);
inputSize = [224, 224, 3];
augimdsTrain = augmentedImageDatastore(inputSize, imdsTrain, 'ColorPreprocessing', 'gray2rgb', 'DispatchInBackground', true);
augimdsValidation = augmentedImageDatastore(inputSize, imdsValidation, 'ColorPreprocessing', 'gray2rgb', 'DispatchInBackground', true);
augimdsTest = augmentedImageDatastore(inputSize, imdsTest, 'ColorPreprocessing', 'gray2rgb');
options = trainingOptions('adam', ...
'MiniBatchSize', miniBatchSize, ...
'MaxEpochs',120, ...
'InitialLearnRate',1e-4, ...
'LearnRateSchedule', 'piecewise', ...
'LearnRateDropFactor', 0.25, ...
'LearnRateDropPeriod', 5, ...
'DispatchInBackground', true, ...
'Shuffle','every-epoch', ...
'ValidationData', augimdsValidation, ...
'ValidationFrequency', 20, ...
'Verbose',true, ...
'Plots','training-progress', ...
'ExecutionEnvironment', 'auto');
tic
alexNetModel = trainNetwork(augimdsTrain,layers,options);
fprintf('training process time cost: ');
toc
[YPred,scores] = classify(alexNetModel,augimdsTest);
YTest = imdsTest.Labels;
accuracy = mean(YPred == YTest);
fprintf('test acc: %f\n', accuracy);
figure
confusionchart(YTest, YPred)
my computer is a lenovo laptop called r9000k 2021 with rtx3080 laptop GPU, and the utilization ratio is shown as follow:
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!