Memory usage during model fit

Due to limited funds I have been doing some experiments on a Raspbery Pi.

I’m currently training a model and the memory usage (global) is always bellow 1.5Gb.
I had access to a Jetson and when running the same code the memory ( 3Gb availble before starting to run ) was exausted and had memory allocation errors.

On the Raspberry the Tensorflow version is 1.14.0 and on the Jetson 2.5.0.

The model I’m trying to fit:

model = Sequential()
model.add(Conv2D(filters=64,
kernel_size=(5, 5),
activation=“relu”,
dtype=‘float16’,
input_shape=(trainSize[0],trainSize[1],3 if trainMode == ‘COLOR’ else 1)))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.10))
model.add(Conv2D(filters=64,
kernel_size=(5, 5),
activation=‘relu’))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.10))
model.add(Conv2D(filters=64,
kernel_size=(3, 3),
activation=“relu”))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.10))
model.add(Conv2D(filters=64,
kernel_size=(3, 3),
activation=‘relu’))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(256,
dtype=‘float16’,
activation=‘relu’))
model.add(Dropout(0.25))
model.add(Dense(256,
dtype=‘float16’,
activation=‘relu’))
model.add(Dropout(0.25))
model.add(Dense(256,
dtype=‘float16’,
activation=‘relu’))
model.add(Dropout(0.10))
model.add(Dense(int(outputs*1.5),
dtype=‘float16’,
activation=‘relu’))
model.add(Dropout(0.10))
model.add(Dense(outputs,
activation=‘sigmoid’))

model.compile(optimizer=‘adam’,
loss=[keras.losses.MeanAbsoluteError()],
metrics=[keras.metrics.Precision(),keras.metrics.AUC(),‘accuracy’])
model.fit(sequence,
epochs=epochs,
steps_per_epoch = int(trainNumber/batchSize),
validation_steps = int(validationNumber/batchSize),
validation_data=validation,
verbose = False,
callbacks = callback)

What can cause the difference in memory usage between GPU and CPU based training?

What am I missing?

Have you tried with:

https://www.tensorflow.org/api_docs/python/tf/config/experimental/set_memory_growth