please add option to load fine-tuned file to CPU if trained on GPU
See original GitHub issueI fine-tuned the pytorch_model.bin on a GPU machine (google cloud) but need to use it on my home computer (no GPU). When I tried to open it using model = BertForMaskedLM.from_pretrained(bert_version) I got the following error:
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='cpu'
to map your storages to the CPU.
Perhaps you can add an option into from_pretrained() such as cpu=True which will then call
torch.load(weights_path, map_location=lambda storage, location: 'cpu')
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Fine-tune a pretrained model - Hugging Face
This is known as fine-tuning, an incredibly powerful training technique. In this tutorial, you will fine-tune a pretrained model with a deep learning...
Read more >Saving and loading models across devices in PyTorch
When loading a model on a CPU that was trained with a GPU, pass torch.device('cpu') to the map_location argument in the torch.load() function....
Read more >Inference and train with existing models and standard datasets
It is usually used for finetuning. Training on CPU. The process of training on the CPU is consistent with single GPU training. We...
Read more >Fine-Tune a Pretrained Deep Learning Model - Esri
If you are unfamiliar with the process of setting up a deep learning ... You can also create training data to fine-tune the...
Read more >NeMo ASR Configuration Files - NVIDIA Documentation Center
Any initialization parameter that is accepted for the Dataset class used in the experiment can be set in the config file. Refer to...
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 Free
Top 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

Would love some explanation on how to do this as well!
same