I’d like to alternate inference and training in a Resnet-type model, but I need to reconfigure it during inference, and I have some questions about that.


Can I unload the model from the gpu by calling model.to(‘cpu’), make a modified copy (and run it on the gpu), and then move the original back to gpu by calling model.to(‘gpu’)?  In other words, is moving the model gpu->cpu->gpu a lossless operation?  (And what happens to the parameters that were passed to the optimizer?  I don’t want to lose the optimizer state)


What is the best way to make a copy of an in-memory model?  I can save it and then reload a copy, but not sure if that is necessary just to copy.


If I want to run inference in half precision (more than 2x faster in this case), can I change the model to half and then change it back?  Is that lossless?  (ie - does the model keep a copy of everything, or does it replace weights with half-precision in place?)