colossalai.utils.memory
- colossalai.utils.memory.bytes_to_GB(val, decimal=2)
A byte-to-Gigabyte converter, defaultly using binary notation.
- Parameters
val – X bytes to convert
- Returns
X’ GB
- colossalai.utils.memory.bytes_to_MB(val, decimal=2)
A byte-to-Megabyte converter, defaultly using binary notation.
- Parameters
val – X bytes to convert
- Returns
X’ MB
- colossalai.utils.memory.report_memory_usage(message, logger=None, report_cpu=False)
Calculate and print RAM usage (in GB)
- Parameters
message (str) – A prefix message to add in the log
logger (
colossalai.logging.DistributedLogger, optional) – An instance ofcolossalai.logging.DistributedLoggerreport_cpu (bool, optional) – Whether to report CPU memory
- Raises
EnvironmentError – Raise error if no distributed environment has been initialized