memory_usage

paddle.fluid.contrib.memory_usage_calc. memory_usage ( program, batch_size ) [source]

Get the estimate memory usage of program with input batch size.

Parameters
  • program (Program) – The current Program.

  • batch_size (int) – The current input data batch_size.

Returns

the estimate memory usage lower bound. max_total_memory(float): the estimate memory usage upper bound. unit_str(string): the unit of estimate usage result.

Return type

min_total_memory(float)

Examples

>>> import paddle.fluid as fluid
>>> lower_usage, upper_usage, unit = fluid.contrib.memory_usage(
        fluid.default_main_program(), batch_size=10)
>>> print "memory usage is about %.3f - %.3f %s" % \
        (lower_usage, upper_usage, unit)