mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
commit
This commit is contained in:
parent
89e3f81520
commit
a77b8126d0
1 changed files with 10 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
|
import gc
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -580,6 +581,15 @@ class LoraFinetuningSingleDevice:
|
||||||
checkpoint.training_metrics = training_metrics
|
checkpoint.training_metrics = training_metrics
|
||||||
checkpoints.append(checkpoint)
|
checkpoints.append(checkpoint)
|
||||||
|
|
||||||
|
# clean up the memory after training finishes
|
||||||
|
self._model.to("cpu")
|
||||||
|
del self._model
|
||||||
|
gc.collect()
|
||||||
|
torch.cuda.empty_cache()
|
||||||
|
|
||||||
|
print("Allocated:", torch.cuda.memory_allocated() / 1e6, "MB")
|
||||||
|
print("Reserved: ", torch.cuda.memory_reserved() / 1e6, "MB")
|
||||||
|
|
||||||
return (memory_stats, checkpoints)
|
return (memory_stats, checkpoints)
|
||||||
|
|
||||||
async def validation(self) -> Tuple[float, float]:
|
async def validation(self) -> Tuple[float, float]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue