chainer.function_hooks.CupyMemoryProfileHook¶
-
class
chainer.function_hooks.
CupyMemoryProfileHook
[source]¶ Function hook for measuring memory usage of functions in cupy memory pool.
Example
Code example:
from chainer.function_hooks import CupyMemoryProfileHook hook = CupyMemoryProfileHook() with hook: trainer.run() hook.print_report()
Output example:
FunctionName UsedBytes AcquiredBytes Occurrence LinearFunction 5.16GB 179.98MB 3900 ReLU 991.82MB 458.97MB 2600 SoftmaxCrossEntropy 7.71MB 5.08MB 1300 Accuracy 617.97KB 351.00KB 700
where FunctionName is the name of function that calls the hook, and UsedBytes is the memory bytes the function used from cupy memory pool, and AcquiredBytes is the actual memory bytes the cupy memory pool acquired from GPU device on the function call, and Occurrence is the number of calls.
Variables: call_history – List of measurement results. It consists of the function that calls this hook, the memory bytes the function used from cupy memory pool, and the memory bytes the cupy memory pool acquired from GPU device on the function call. Methods
-
added
(function=None)[source]¶ Callback function invoked when a function hook is added
Parameters: function (FunctionNode) – Function object to which the function hook is added.
-
backward_postprocess
(function, in_data, out_grad)[source]¶ Callback function invoked after backward propagation.
Parameters: - function (FunctionNode) – Function object to which the function hook is registered.
- in_data (tuple of numpy.ndarray or tuple of cupy.ndarray) – Input of forward propagation.
- out_grad (tuple of numpy.ndarray or tuple of cupy.ndarray) – Gradient data of backward propagation.
-
backward_preprocess
(function, in_data, out_grad)[source]¶ Callback function invoked before backward propagation.
Parameters: - function (FunctionNode) – Function object to which the function hook is registered.
- in_data (tuple of numpy.ndarray or tuple of cupy.ndarray) – Input data of forward propagation.
- out_grad (tuple of numpy.ndarray or tuple of cupy.ndarray) – Gradient data of backward propagation.
-
deleted
(function=None)[source]¶ Callback function invoked when a function hook is deleted
Parameters: function (FunctionNode) – Function object to which the function hook is deleted.
-
forward_postprocess
(function, in_data)[source]¶ Callback function invoked after forward propagation.
Parameters: - function (FunctionNode) – Function object to which the function hook is registered.
- in_data (tuple of numpy.ndarray or tuple of cupy.ndarray) – Input data of forward propagation.
-
forward_preprocess
(function, in_data)[source]¶ Callback function invoked before forward propagation.
Parameters: - function (FunctionNode) – Function object to which the function hook is registered.
- in_data (tuple of numpy.ndarray or tuple of cupy.ndarray) – Input data of forward propagation.
-
print_report
(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶ Prints a summary report of memory profiling in functions.
-
summary
()[source]¶ Returns a summary of memory profiling in functions.
Returns: A summarized dictionary whose keys are function names and values are dictionaries of used_bytes
,acquired_bytes
, andoccurrrence
.
Attributes
-
name
= 'CupyMemoryProfileHook'¶
-