Mounting a Persistent Volume
The first thing you’ll do is mount a Persistent Volume to the Beam runtime in order to save your model weights. Add the following line to the file with yourapp.py
:
Saving model checkpoints
During your training loop, you can calltorch.save()
to dump the model weights to a file path. In this case, the file path is a Persistent Volume you’ve defined in app.py
.
Loading model checkpoints
You can load model weights using theload_state_dict()
method, by passing in the Persistent Volume path from the previous step.