You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am trying to load model and predict in CPU only machine,
which is trained with GPU machine.
I tried following code:
tabular_model = TabularModel.load_model("md_tmp2", map_location=torch.device('cpu'))
But error comes out:
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
Please let me know how to deal with this.
Desktop:
OS: Windows
Version
pytorch_tabular 1.1.1
torch 2.5.1+cu124(GPU Machine), torch 2.5.1(CPU Only machine)
The text was updated successfully, but these errors were encountered:
Hey @arcturus9725! 👋 I'm here to help you with your code issues and questions. Let's squash those bugs together!
To resolve the issue of loading a model trained on a GPU machine and predicting on a CPU-only machine, you should ensure that the map_location argument is correctly set to 'cpu' when using TabularModel.load_model. Here's how you can do it:
frompytorch_tabularimportTabularModel# Load the model with map_location set to 'cpu'tabular_model=TabularModel.load_model("md_tmp2", map_location='cpu')
By setting map_location='cpu', the model will be loaded onto the CPU, which should prevent the error you're encountering [1].
from pytorch_tabular import TabularModel
tabular_model = TabularModel.load_model("md_tmp2", map_location='cpu')
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
Hello,
I am trying to load model and predict in CPU only machine,
which is trained with GPU machine.
I tried following code:
tabular_model = TabularModel.load_model("md_tmp2", map_location=torch.device('cpu'))
But error comes out:
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
Please let me know how to deal with this.
Desktop:
The text was updated successfully, but these errors were encountered: