ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

High memory consumption for Convolution Layer

Open mkamrao opened this issue 9 years ago • 12 comments

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

mkamrao avatar Apr 19 '17 12:04 mkamrao

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

mkamrao avatar Apr 19 '17 12:04 mkamrao

  • 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 ?)

AnthonyBarbier avatar Apr 19 '17 13:04 AnthonyBarbier

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

mkamrao avatar Apr 19 '17 17:04 mkamrao

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.

developer-compute avatar Apr 19 '17 22:04 developer-compute

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

mkamrao avatar Apr 20 '17 06:04 mkamrao

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.

mpflanzer avatar Apr 20 '17 11:04 mpflanzer

Hello

Thank you. When is the release with fix expected.

Kamrao

mkamrao avatar Apr 20 '17 11:04 mkamrao

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?

sherwin29 avatar Apr 23 '17 13:04 sherwin29

Hi...

Any update on when the next release with the fix is expected. Thanks

Kamrao

mkamrao avatar May 01 '17 11:05 mkamrao

Sorry for the wait. Hopefully by the end of the week.

AnthonyBarbier avatar May 03 '17 12:05 AnthonyBarbier

Hello @mkamrao, Fix has been applied in v17.05 release. Can you check if this solves your issue?

GeorgeARM avatar May 04 '17 11:05 GeorgeARM

Hello

Memory consumption is better now (~70MB), but higher than expected. Is this due to memory padding? Can this be reduced further? Thanks

kamrao

mkamrao avatar May 10 '17 08:05 mkamrao