필터 지우기
필터 지우기

Why does matlab.io.​datastore.​MiniBatcha​ble not support paralle processing (multi-gpu training)

조회 수: 3 (최근 30일)
For my application, I need to arrange data in a specific order when they are fed into the CNN during the training stage. To do so, I implemented a custom mini-batchable datastore called CmapDatastore that inherits from the matlab.io.datastore.MiniBatchable class. It works fine with single GPU in training a CNN model. However, when I try to use multiple GPUs in training by setting trainingOptions as:
trainingOptions( ..........
'ExecutionEnvironment', 'multi-gpu', .......)
The error message is:
The MiniBatchable Datastore CmapDatastore does not support parallel operations.
The code of CmapDatastore.m is attached to this messsage.
I would appreciate your help greatly.
Many thanks,
Yong

채택된 답변

Yoann Roth
Yoann Roth 2022년 3월 14일
Hello Yong,
To support parallel training for your custom datastore, you need to select the one of the following option
  • Implement MiniBatchable + PartitionableByIndex (see here)
  • Implement Partitionable. This is what is documented here.
Unfortunately, you implemented MiniBatchable + Partitionable and this is not the correct combination.
Usually, the recommendation is just to stick to datastores that we ship (e.g. fileDatastore), and to use the transform function to modify it appropriately.
In your case, it seems that the choice of a custom datastore is justified because the data seems to have a specific structure and shuffle and partition behave in a specific way.
To support parallel training, you could
  • Implement partitionableByIndex it it is not too much effort. It sort of seems that because of the structure of the data, it might not be possible to index it directly.
  • Otherwise, remove the MiniBatchable interface from your datastore, and modify read to not return a table but just a row of data, like so
function [data,info] = read(ds)
info = struct;
data = {read(ds.Datastore), ds.Labels(ds.CurrentFileIndex)};
ds.CurrentFileIndex = ds.CurrentFileIndex + 1;
end
This will put your datastore in the case Partitionable only and should support the multi-gpu option.
  댓글 수: 4
Yoann Roth
Yoann Roth 2022년 3월 15일
Hi Yong,
Your custom datastore does not have to be "MiniBatchable" to be supported.
Having a custom datastore that is only "Partitionable" will work, and support Parallel training.
Yoann
Yong
Yong 2022년 3월 16일
Hi Yoann,
Thank you very much for your response. Yes, you are correct that Paritionable datastore will work with trainNet.
I have another question: because the read function in Partitionable reads only one file at a time, it seems that when multiple-gpus are used in training, the datastore might be partitioned into segments that don't follow my specific requirement, i.e. the data files are read in a gruop of at least 4 files, and the files are in the order of x, x_rotated_90, x_roated_180 and x_rotated_270. I arrange the files in that order in the datastore. Any suggestion to work around?
Many thanks,
Yong

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel and Cloud에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by