Gpu out of memory

question

#1

i’m running the following sentence of codes one by one. And there occur a problem in the following.

julia> rel2_1=relu.(con2_1.+KnetArray(reshape(map(Float32,weights["b2_1"]),1,1,size(weights["b2_1"],1),1)));
ERROR: Out of gpu memory
function vgg_m(x0,weights)

con1_1=conv4(KnetArray(map(Float32,weights["w1_1"])),KnetArray(map(float32,x0));padding=1);
rel1_1=relu.(con1_1.+ KnetArray(reshape(map(Float32,weights["b1_1"]),1,1,size(weights["b1_1"],1),1)));

con1_2=conv4(KnetArray(map(Float32,weights["w1_2"])),rel1_1;padding=1);
rel1_2=relu.(con1_2.+ KnetArray(reshape(map(Float32,weights["b1_2"]),1,1,size(weights["b1_2"],1),1)));
x1_2=pool(rel1_2);

con2_1=conv4(KnetArray(map(Float32,weights["w2_1"])),x1_2;padding=1);
rel2_1=relu.(con2_1.+ KnetArray(reshape(map(Float32,weights["b2_1"]),1,1,size(weights["b2_1"],1),1)));

con2_2=conv4(KnetArray(map(Float32,weights["w2_2"])),rel2_1;padding=1);
rel2_2=relu.(con2_2.+ KnetArray(reshape(map(Float32,weights["b2_2"]),1,1,size(weights["b2_2"],1),1)));
x2_2=pool(rel2_2)

con3_1=conv4(KnetArray(map(Float32,weights["w3_1"])),x2_2;padding=1);
rel3_1=relu.(con3_1.+ KnetArray(reshape(map(Float32,weights["b3_1"]),1,1,size(weights["b3_1"],1),1)));

con3_2=conv4(KnetArray(map(Float32,weights["w3_2"])),rel3_1;padding=1);
rel3_2=relu.(con3_2.+ KnetArray(reshape(map(Float32,weights["b3_2"]),1,1,size(weights["b3_2"],1),1)));

con3_3=conv4(KnetArray(map(Float32,weights["w3_3"])),rel3_2;padding=1);
rel3_3=relu.(con3_3.+ KnetArray(reshape(map(Float32,weights["b3_3"]),1,1,size(weights["b3_3"],1),1)));
x3_3=pool(rel3_3)

con4_1=conv4(KnetArray(map(Float32,weights["w4_1"])),x3_3;padding=1);
rel4_1=relu.(con4_1.+ KnetArray(reshape(map(Float32,weights["b4_1"]),1,1,size(weights["b4_1"],1),1)));

con4_2=conv4(KnetArray(map(Float32,weights["w4_2"])),rel4_1;padding=1);
rel4_2=relu.(con4_2.+ KnetArray(reshape(map(Float32,weights["b4_2"]),1,1,size(weights["b4_2"],1),1)));

con4_3=conv4(KnetArray(map(Float32,weights["w4_3"])),rel4_2;padding=1);
rel4_3=relu.(con4_3.+ KnetArray(reshape(map(Float32,weights["b4_3"]),1,1,size(weights["b4_3"],1),1)));
x4_3=pool(rel4_3)

con5_1=conv4(KnetArray(map(Float32,weights["w5_1"])),x4_3;padding=1);
rel5_1=relu.(con5_1.+ KnetArray(reshape(map(Float32,weights["b5_1"]),1,1,size(weights["b5_1"],1),1)));

con5_2=conv4(KnetArray(map(Float32,weights["w5_2"])),rel5_1;padding=1);
rel5_2=relu.(con5_2.+ KnetArray(reshape(map(Float32,weights["b5_2"]),1,1,size(weights["b5_2"],1),1)));

con5_3=conv4(KnetArray(map(Float32,weights["w5_3"])),rel5_2;padding=1);
rel5_3=relu.(con5_3.+ KnetArray(reshape(map(Float32,weights["b5_3"]),1,1,size(weights["b5_3"],1),1)));
x5_3=pool(rel5_3);

con6=conv4(KnetArray(map(Float32,weights["w6"])),x5_3;padding=1);
rel6=relu.(con.+ KnetArray(reshape(map(Float32,weights["b6"]),1,1,size(weights["b6"],1),1)));
return rel6

end