2017-04-05 12 views
1

Ich bekomme einen Speicherfehler beim Versuch, Bildfunktionen mit Keras aus VGG19-Netzwerk zu extrahieren (läuft auf der CPU). Werte für Fortschritte scheinen unglaublich hoch und ich bin nicht sicher, was sie bedeuten, könnte es verwandt sein? Das hochgeladene Bild ist zunächst 736 x 491, wird aber auf 224 x 224 verkleinert, bevor es in das Netzwerk eingespeist wird.RuntimeError: CorrMM konnte Arbeitsspeicher von 576 x 50176 nicht zuweisen

RuntimeError: CorrMM failed to allocate working memory of 576 x 50176 

Apply node that caused the error: CorrMM{half, (1, 1)} (Elemwise{Composite{(i0 * (Abs((i1 + i2)) + i1 + i2))}}[(0, 1)].0, Subtensor{::, ::, ::int64, ::int64}.0) 
Toposort index: 77 
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)] 
Inputs shapes: [(1, 64, 224, 224), (64, 64, 3, 3)] 
Inputs strides: [(12845056, 200704, 896, 4), (4, 256, -49152, -16384)] 
Inputs values: ['not shown', 'not shown'] 
Outputs clients: [[Elemwise{Composite{(i0 * (Abs((i1 + i2)) + i1 + i2))}}[(0, 1)](TensorConstant{(1, 1, 1, 1) of 0.5}, CorrMM{half, (1, 1)}.0, InplaceDimShuffle{0,3,1,2}.0)]] 

-Code, die ich laufen werde:

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) 
model_features = model.predict(x) 
total_sum = sum(model_features[0]) 
features_norm = np.array([val/total_sum for val in model_features[0]], dtype=np.float32) 

Form und Modell Zusammenfassung

x shape (1, 3, 224, 224) 
____________________________________________________________________________________________________ 
Layer (type)      Output Shape   Param #  Connected to      
==================================================================================================== 
input_1 (InputLayer)    (None, 3, 224, 224) 0            
____________________________________________________________________________________________________ 
block1_conv1 (Convolution2D)  (None, 64, 224, 224) 1792  input_1[0][0]      
____________________________________________________________________________________________________ 
block1_conv2 (Convolution2D)  (None, 64, 224, 224) 36928  block1_conv1[0][0]    
____________________________________________________________________________________________________ 
block1_pool (MaxPooling2D)  (None, 64, 112, 112) 0   block1_conv2[0][0]    
____________________________________________________________________________________________________ 
block2_conv1 (Convolution2D)  (None, 128, 112, 112) 73856  block1_pool[0][0]     
____________________________________________________________________________________________________ 
block2_conv2 (Convolution2D)  (None, 128, 112, 112) 147584  block2_conv1[0][0]    
____________________________________________________________________________________________________ 
block2_pool (MaxPooling2D)  (None, 128, 56, 56) 0   block2_conv2[0][0]    
____________________________________________________________________________________________________ 
block3_conv1 (Convolution2D)  (None, 256, 56, 56) 295168  block2_pool[0][0]     
____________________________________________________________________________________________________ 
block3_conv2 (Convolution2D)  (None, 256, 56, 56) 590080  block3_conv1[0][0]    
____________________________________________________________________________________________________ 
block3_conv3 (Convolution2D)  (None, 256, 56, 56) 590080  block3_conv2[0][0]    
____________________________________________________________________________________________________ 
block3_conv4 (Convolution2D)  (None, 256, 56, 56) 590080  block3_conv3[0][0]    
____________________________________________________________________________________________________ 
block3_pool (MaxPooling2D)  (None, 256, 28, 28) 0   block3_conv4[0][0]    
____________________________________________________________________________________________________ 
block4_conv1 (Convolution2D)  (None, 512, 28, 28) 1180160  block3_pool[0][0]     
____________________________________________________________________________________________________ 
block4_conv2 (Convolution2D)  (None, 512, 28, 28) 2359808  block4_conv1[0][0]    
____________________________________________________________________________________________________ 
block4_conv3 (Convolution2D)  (None, 512, 28, 28) 2359808  block4_conv2[0][0]    
____________________________________________________________________________________________________ 
block4_conv4 (Convolution2D)  (None, 512, 28, 28) 2359808  block4_conv3[0][0]    
____________________________________________________________________________________________________ 
block4_pool (MaxPooling2D)  (None, 512, 14, 14) 0   block4_conv4[0][0]    
____________________________________________________________________________________________________ 
block5_conv1 (Convolution2D)  (None, 512, 14, 14) 2359808  block4_pool[0][0]     
____________________________________________________________________________________________________ 
block5_conv2 (Convolution2D)  (None, 512, 14, 14) 2359808  block5_conv1[0][0]    
____________________________________________________________________________________________________ 
block5_conv3 (Convolution2D)  (None, 512, 14, 14) 2359808  block5_conv2[0][0]    
____________________________________________________________________________________________________ 
block5_conv4 (Convolution2D)  (None, 512, 14, 14) 2359808  block5_conv3[0][0]    
____________________________________________________________________________________________________ 
block5_pool (MaxPooling2D)  (None, 512, 7, 7)  0   block5_conv4[0][0]    
____________________________________________________________________________________________________ 
flatten (Flatten)    (None, 25088)   0   block5_pool[0][0]     
____________________________________________________________________________________________________ 
fc1 (Dense)      (None, 4096)   102764544 flatten[0][0]      
____________________________________________________________________________________________________ 
fc2 (Dense)      (None, 4096)   16781312 fc1[0][0]       
==================================================================================================== 
Total params: 139,570,240 
Trainable params: 139,570,240 
Non-trainable params: 0 
+0

: D - Können Sie 'x.shape' und' model.summary() 'ausdrucken? Sie versuchen, mehr als 6 GB Speicher zuzuweisen - und das verursacht Probleme mit Ihrem 'RAM'. –

+0

@ MarcinMożejko druckte sie aus :) –

+0

Wie viel von 'RAM' Speicher hat Ihre Maschine? Und ist dieser Fehler vorher passiert? –

Antwort

1

Das Problem in diesem VGG19 Architektur liegt braucht etwa 250MB pro Probe in einer Inferenz-Phase. Der Standardwert von batch_size=32 so Modell versucht, über 8GB Speicher zuweisen, die viel mehr als OPs Maschine war.

Verwandte Themen