Saving one single inference example per validation stage #10223
-
I would like to save one single inference example per validation stage. To this end I came up with:
This works OK when running on a single device (CPU) but when running on GPUs on a slurm cluster I get:
I guess because the data has not been sent to the same device as the model. This seems like a problem that must have been solved before. Can anyone suggest a typical pytorch-lightning way of doing this? Thanks for your input |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
here: x, y = (d.unsqueeze(0) for d in self.trainer.datamodule.valid_set.dataset_pair()) I think this is something not part of the dataloader, so PL won't move to the device automatically. x = x.to(self.device)
y_hat = self.model(x)
... |
Beta Was this translation helpful? Give feedback.
here:
I think this is something not part of the dataloader, so PL won't move to the device automatically.
you can do: