Skip to content

Instantly share code, notes, and snippets.

@tchaton
Created July 20, 2021 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tchaton/bdf82eeb4b22992e0a2a75db90e7684d to your computer and use it in GitHub Desktop.
Save tchaton/bdf82eeb4b22992e0a2a75db90e7684d to your computer and use it in GitHub Desktop.
from pytorch_lightning import Trainer
from pytorch_lightning.plugins import DeepSpeedPlugin
# Enable CPU Offloading
model = MyModel()
trainer = Trainer(gpus=4, plugins='deepspeed_stage_3_offload', precision=16)
trainer.fit(model)
# Enable CPU Offloading, and offload parameters to CPU
model = MyModel()
trainer = Trainer(
gpus=4,
plugins=DeepSpeedPlugin(
stage=3,
offload_optimizer=True,
offload_parameters=True,
remote_device='nvme',
offload_params_device='nvme',
offload_optimizer_device='nvme',
nvme_path = '/local_nvme'
),
precision=16
)
trainer.fit(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment