Resource Exhausted Keras Resnet50

Hi Experts

When I run the following code on tx1:
import numpy as np
from keras.applications.imagenet_utils import preprocess_input,decode_predictions
from keras import applications

model = applications.ResNet50(weights=‘imagenet’)
img_path = ‘elephant-vid-tout.jpg’
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
#x = preprocess_input(x)
preds = model.predict(x)
print(‘Predicted:’, decode_predictions(preds, top=3)[0])

I get the error:

2018-09-11 20:54:33.831463: W tensorflow/core/framework/] OP_REQUIRES failed at : Resource exhausted: OOM when allocating tensor with shape[3,3,256,256] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc

Any ideas?

(I run Jetpack 3.3, tf 1.10). I also bootfs from micro sd.



The error means out of memory.

Please remember that the TX1 only has 4G memory.
You can monitor system status with our script:

sudo ./tegrastats

A possible solution is to upgrade your device to TX2 which has double memory size.

Hi AastaLLL

I got it to work. Instead of running it from Jupyter Notebook I ran as py file.