Hi everyone, I am wondering what is the best way to load the model and start making inference on CPU after training the model on GPU:
What I am doing which is working fine but seems inefficient is as follows:
1- Load the data
2- Define, data loader
3- Define network architecture
4- Train the model
5- Save the model using
torch.save(self.net.state_dict(), save_path)
Then when I go to inference and prediction on CPU, I do the following:
1- Load data
2- Define dataloader
3- Define network
4 - Load the model and checkpoint
5- Prediction on new data
model.load_state_dict(torch.load(path,map_location=‘cpu’))
I tried to do the prediction without steps 1-3 since I thought the saved model and checkpoint has all information but then I got an error.
I am wondering if there is any way to make this procedure more efficient and faster.