MATLAB: GPU arrays support only fundamental numeric or logical data types

deep learninggpu

I tried to use Faster R-CNN with the pretrained model of ResNet18 where I froze some of the layers to detect 5 different objects inside image. I've successfully train the model using only the training data (in table). However when I include the validation data, the MATLAB asked me to change the validation and training data to be in datastore format (basically I followed the steps here https://www.mathworks.com/help/vision/ug/object-detection-using-faster-r-cnn-deep-learning.html). I've tried to train the model, the training can go on, but there is a pop-up warning for every iteration(?) saying the GPU arrays support only fundamental numeric or logical data types. Also, the training plot for loss function can't be shown.
load data.mat
lgraph=resnet18_12_freeze
%trainingData
imds = imageDatastore(trainingData.imageFilename);
blds = boxLabelDatastore(trainingData(:,2:end));
trainingData=combine(imds,blds);
%validationData
imds = imageDatastore(validationData.imageFilename);
blds = boxLabelDatastore(validationData(:,2:end));
validationData=combine(imds,blds);
inputSize = [224 224 3];
trainingData = transform(trainingData, @(data)preprocessData(data,inputSize));
augmentedTrainingData = transform(trainingData,@augmentData);
augmentedData = cell(4,1);
trainingData = transform(augmentedTrainingData,@(data)preprocessData(data,inputSize));
validationData = transform(validationData,@(data)preprocessData(data,inputSize));
options = trainingOptions('sgdm', ...
'MiniBatchSize', 2, ...
'InitialLearnRate', 1e-3, ...
'MaxEpochs', 50, ...
'VerboseFrequency', 50, ...
'ValidationData', validationData, ...
'ValidationFrequency',50, ...
'ExecutionEnvironment', 'gpu', ...
'CheckpointPath', tempdir, ...
'Plots','training-progress');
detector = trainFasterRCNNObjectDetector(trainingData, lgraph, options, ...
'NegativeOverlapRange',[0.1 0.5], ...
'PositiveOverlapRange',[0.5 1]);
Warning message
Warning: GPU arrays support only fundamental numeric or logical data types.
> In nnet.internal.cnn.util/TrainingPlotReporter/cleanUpAfterPlotError (line 109)
In nnet.internal.cnn.util/TrainingPlotReporter/reportIteration (line 58)
In nnet.internal.cnn.util/VectorReporter/computeAndReport (line 64)
In nnet.internal.cnn.util/VectorReporter/reportIteration (line 20)
In nnet.internal.cnn/Trainer/train (line 142)
In vision.internal.cnn.trainNetwork (line 102)
In trainFasterRCNNObjectDetector>iTrainEndToEnd (line 901)
In trainFasterRCNNObjectDetector (line 428)
In trainFasterRCNN (line 35)

Best Answer

It looks distinctly like one of your custom functions, preprocessData or augmentData, is doing something illegal with gpuArray objects. Try calling dbstop if all error so that MATLAB will break at the problematic line of code.