memory¶
Functions
Garbage collection Torch (CUDA) memory. |
|
Deprecated since version v1.5. |
|
Deprecated since version v1.5. |
|
Calculates the size of a Module in megabytes. |
|
|
|
|
|
|
|
|
|
Detach all tensors in in_dict. |
Utilities related to memory.
- pytorch_lightning.utilities.memory.garbage_collection_cuda()[source]¶
Garbage collection Torch (CUDA) memory.
- Return type
- pytorch_lightning.utilities.memory.get_gpu_memory_map()[source]¶
Deprecated since version v1.5: This function was deprecated in v1.5 in favor of pytorch_lightning.accelerators.gpu._get_nvidia_gpu_stats and will be removed in v1.7.
Get the current gpu usage.
- Return type
- Returns
A dictionary in which the keys are device ids as integers and values are memory usage as integers in MB.
- Raises
FileNotFoundError – If nvidia-smi installation not found
- pytorch_lightning.utilities.memory.get_memory_profile(mode)[source]¶
Deprecated since version v1.5: This function was deprecated in v1.5 in favor of pytorch_lightning.accelerators.gpu._get_nvidia_gpu_stats and will be removed in v1.7.
Get a profile of the current memory usage.
- Parameters
There are two modes:
’all’ means return memory for all gpus
’min_max’ means return memory for max and min
- Return type
- Returns
A dictionary in which the keys are device ids as integers and values are memory usage as integers in MB. If mode is ‘min_max’, the dictionary will also contain two additional keys:
’min_gpu_mem’: the minimum memory usage in MB
’max_gpu_mem’: the maximum memory usage in MB
- pytorch_lightning.utilities.memory.get_model_size_mb(model)[source]¶
Calculates the size of a Module in megabytes.
The computation includes everything in the
state_dict()
, i.e., by default the parameters and buffers.- Return type
- Returns
Number of megabytes in the parameters of the input module.