Moving trained model between devices
See original GitHub issueHello!
Is there a way to move the trained SetFit model to another device?
E.g. I train a model on a GPU, and after initializing the model on a CPU-only machine I get
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.
I have managed to fix the error by running:
model.model_body = model.model_body.to("cpu")
model.model_head = model.model_head.to("cpu")
However, I guess it depends on the type of the head (in case of the Logistic regression head there is no need to move it).
If there is no single method to move a model between devices, shall I open a PR?
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
What Does it Take to Train Deep Learning Models On-Device?
The key thing to realize is that there are two different stages to training a model. The first is building the back-propagation machinery...
Read more >On-Device Training with TensorFlow Lite
Setup · Classify images of clothing · Build a model for on-device training · Prepare the data · Train the model · Convert...
Read more >Training on the device - Machine, Think!
To be fair, you often don't need to train a model from scratch. Most people take a pre-trained model and then use transfer...
Read more >How to Distribute Deep Learning Model Training?
This post details why you need to distribute the model training, different distribution strategies, and how they work. Finally, how to apply ...
Read more >Training and deploying ML models on edge devices (TF Fall ...
Learn how to train and deploy an ML model on an Android app in just a few lines of code with TensorFlow Lite...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have also come across this exact issue - it would be awesome to have some .to(device) functionality for the SetFitModel class!
Thank you for your detailed explanation! I guess the error raised because of the initialization method of SetFitHead. Will validate my guess shortly.
Thanks again for raising this up!