We lately upgraded tensorflow 2.3 to tensorflow2.8.
We encounter serious memory issues. We get out of memory.
With the same script we can put x11 in the gpu virtual memory.
Can we use tensorflow2.8 with p100 gpu card?
Environment
TensorRT Version: None
GPU Type: P100
Nvidia Driver Version: 460.27.04
CUDA Version: 11.2
CUDNN Version: 8.2.1.32
Operating System + Version: Ubuntu 18.04.4 LTS
Python Version (if applicable): 3.10
TensorFlow Version (if applicable): 2.8
PyTorch Version (if applicable): NA
Baremetal or Container (if container which image + tag): NA
Code:
import tensorflow as tf
import numpy as np
from tensorflow.keras.layers import Dense, Dropout, Input, GlobalAveragePooling2D, Conv2D, MaxPooling2D
from tensorflow.keras.models import Model
from tensorflow.keras.datasets import cifar10
import cv2
from tensorflow.python.framework.config import set_memory_growth
gpus = tf.config.experimental.list_physical_devices(‘GPU’)
for gpu in gpus:
set_memory_growth(gpu, True)
dim = 224
def create_model():
inputs = Input(shape=(dim, dim, 3), dtype=‘float16’)
resnet = Conv2D(128, 1)(MaxPooling2D()(inputs))
pooling = GlobalAveragePooling2D()(resnet)
dropout = Dropout(0.4, dtype=‘float32’)(pooling)
class_types = [‘airplane’, ‘automobile’, ‘bird’, ‘cat’, ‘deer’,
‘dog’, ‘frog’, ‘horse’, ‘ship’, ‘truck’]
outputs = Dense(len(class_types), activation=“softmax”, dtype=‘float32’)(dropout)
model = Model(inputs=inputs, outputs=outputs)
return model
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train_arr, y_train_arr = ,
for ind in range(len(x_train)):
x_train_arr.append(x_train[ind])
y_train_arr.append(y_train[ind])
for ind in range(len(x_train)):
x_train_arr.append(x_train[ind])
y_train_arr.append(y_train[ind])
for ind in range(len(x_train)):
x_train_arr.append(x_train[ind])
y_train_arr.append(y_train[ind])
for ind in range(len(x_train)):
x_train_arr.append(x_train[ind])
y_train_arr.append(y_train[ind])
x_train_big, x_test_big = ,
for im in x_train_arr:
x_train_big.append(cv2.resize(im, (dim, dim)))
train_lab_categorical = tf.keras.utils.to_categorical(y_train_arr, num_classes=10, dtype=‘uint8’)
from sklearn.model_selection import train_test_split
print(‘train test split’)
train_im, valid_im, train_lab, valid_lab = train_test_split(x_train_big, train_lab_categorical, test_size=0.20,
stratify=train_lab_categorical,
random_state=40, shuffle = True)
print(‘train test split finished’)
model = create_model()
model.summary()
model.compile(loss=‘categorical_crossentropy’, optimizer=tf.optimizers.Adam(learning_rate=5e-4),
metrics=[‘acc’])
history = model.fit(np.array(x_train_big), np.array(train_lab_categorical),
epochs=1, batch_size=128)