High memory consumption for Convolution Layer
Hello
I was trying out neural network creation using the ARM Compute Neon Library.
I have used below configuration parameters for Convolution Layer: conv0.configure(&src, &weights0, &biases0, &out_conv0, PadStrideInfo(2,2,3,3,DimensionRoundingType::FLOOR));
Input dimensions are as below (all data type float): weights - [64773]; biases - [64]; input image - [448448*3];
Output dimesions (all data type float): [224x224x64]
The expected total memory consumption should be less than ~20MB However, the memory consumption noted after execution of above conv0.configure is >250MB
Could you clarify whether this high memory usage is expected. (As memory is main constraint on neural n/ws - I have posed this query).
Thanks kamrao
typo in above query: please read as below weights - [64 x 7 x 7 x 3]; biases - [64]; input image - [448 x 448 x 3];
thanks
- Are you using the latest release ? (17.04)
- Are you using auto padding or accurate padding ( documentation )
- Which function are you using ? (Neon or OpenCL ?)
Hello
Are you using the latest release ? (17.04) Yes, i am using latest release(17.04)
Are you using auto padding or accurate padding ( documentation ) I am not setting any type of padding
Which function are you using ? (Neon or OpenCL ?) I am using the Neon APIs.
Let me know, if any further information is needed.
Thanks Kamrao
Can you please post the code where you initialize, configure, allocate, fill the tensors / functions so that we can try to reproduce on our end?
From: mkamrao [email protected] Sent: 19 Apr 2017 18:00 To: ARM-software/ComputeLibrary Cc: Subscribed Subject: Re: [ARM-software/ComputeLibrary] High memory consumption for Convolution Layer (#54)
Hello
Are you using the latest release ? (17.04) Yes, i am using latest release(17.04)
Are you using auto padding or accurate padding ( documentation ) I am not setting any type of padding
Which function are you using ? (Neon or OpenCL ?) I am using the Neon APIs.
Let me know, if any further information is needed.
Thanks Kamrao
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/ARM-software/ComputeLibrary/issues/54#issuecomment-295345532, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZt0Sn_S4AkWddK3P31KTi0ZcgjEpw2Iks5rxj2zgaJpZM4NBpMn.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hello
Please find the code that was used, pasted below:
constexpr unsigned int width_src_image = 448;
constexpr unsigned int height_src_image = 448;
constexpr unsigned int ifm_src_img = 3;
const TensorShape src_shape(width_src_image, height_src_image, ifm_src_img);
src.allocator()->init(TensorInfo(src_shape, 1, DataType::F32));
// Initialize tensors of conv0
constexpr unsigned int kernel_x_conv0 = 7;
constexpr unsigned int kernel_y_conv0 = 7;
constexpr unsigned int ofm_conv0 = 64;
constexpr unsigned int kernel_x_out = 224;
constexpr unsigned int kernel_y_out = 224;
const TensorShape weights_shape_conv0(kernel_x_conv0, kernel_y_conv0, src_shape.z(), ofm_conv0);
const TensorShape biases_shape_conv0(weights_shape_conv0[3]);
const TensorShape out_shape_conv0(kernel_x_out, kernel_y_out, weights_shape_conv0[3]);
weights0.allocator()->init(TensorInfo(weights_shape_conv0, 1, DataType::F32));
biases0.allocator()->init(TensorInfo(biases_shape_conv0, 1, DataType::F32));
out_conv0.allocator()->init(TensorInfo(out_shape_conv0, 1, DataType::F32));
/* -----------------------End: [Initialize tensors] */
/* [Configure functions] */
conv0.configure(&src, &weights0, &biases0, &out_conv0, PadStrideInfo(2,2,3,3,DimensionRoundingType::FLOOR));
/* -----------------------End: [Configure functions] */
/* [Allocate tensors] */
// Now that the padding requirements are known we can allocate the images:
src.allocator()->allocate();
weights0.allocator()->allocate();
biases0.allocator()->allocate();
out_conv0.allocator()->allocate();
The high memory consumption (>250MB) is noted immediately after conv0.configure in above code. Hence, allocate or filling the tensors may not be needed.
Thanks
Thanks for providing your code. We have been able to reproduce the problem. The high memory consumption is caused by an error in the padding calculation for intermediate tensors in the convolution layer function.
The issue will be fixed in the next release.
Hello
Thank you. When is the release with fix expected.
Kamrao
Hi, It seems that this memory issue also happens when calling OpenCL Api. It works fine when trying to initialize, configure, and allocate 1 or 2 conv layers(with relu/pool/norm) which has the correct results; while for configuring, allocating more layers repeatedly, the error occurs:
ERROR in void arm_compute::Window::validate() const ./arm_compute/core/Window.inl:73: _dims[i].end() <= _dims[i].start() Illegal seek !!!!!!!!!!!!!!!!!!!!!!!!!!!
right after calling layer configure function.
if so, is there a way to share memory usage or to manually free some of the buffer no long used?
Hi...
Any update on when the next release with the fix is expected. Thanks
Kamrao
Sorry for the wait. Hopefully by the end of the week.
Hello @mkamrao, Fix has been applied in v17.05 release. Can you check if this solves your issue?
Hello
Memory consumption is better now (~70MB), but higher than expected. Is this due to memory padding? Can this be reduced further? Thanks
kamrao