Is it possible to load a model that is trained on a TPU saved using ModelCheckpoint on a GPU for inference?
model = LightModel(hparams)
trainer = pl.Trainer(resume_from_checkpoint=str(ckpt), gpus=1)
trainer.test(model)
Tried to normally load the weights as with a GPU but throws an error.
Kaggle GPU
torchvision==0.6.0a0+82fd1c8
torch==1.5.0
pytorch-lightning-0.8.1
Have you tried to load on CPU?
Can you put the error?
RuntimeError: Could not run 'aten::empty_strided' with arguments from the 'XLATensorId' backend. 'aten::empty_strided' is only available for these backends: [CPUTensorId, CUDATensorId, BackendSelect, VariableTensorId].
@Laksh1997 I tried, it still gives the RuntimeError
This looks like a PyTorch Issue and this looks something similar. Your code looks fine, someone senior should take a look I guess. @Borda
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@lezwon mind have look? :]
@ArthDh The fix for this issue is in progress here: https://github.com/PyTorchLightning/pytorch-lightning/pull/3044. The issue is that Lightning as of now saves the model as XLA tensors instead of CPU ones. Hence when you try to load them on GPU they are unable to find an XLA device and hence fail.
@lezwon Thank you for the update!
This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team!