AMP wants the model to be first sent to CUDA device
See original GitHub issueDescribe the bug
When training with fp16
, AMP says that we need to provide a model with parameters located on CUDA.
To Reproduce The problem is reproduced in this Kernel (Version 3).
Expected behavior Expect the model to train normally
Screenshots
Calling runner.train
![](https://habrastorage.org/webt/fd/rp/0i/fdrp0i4u6uzxhyd5wjafuc1k3w0.png)
Getting error:
When using amp.initialize, you need to provide a model with parameters
located on a CUDA device before passing it no matter what optimization level
you chose. Use model.to('cuda') to use the default device.
![](https://habrastorage.org/webt/a1/im/vo/a1imvo0wsnv2vuddgdteglhu0ua.png)
Additional context
The problem is solved if I pass model=model.cuda()
to runner.train
. But I don’t think it’s designed to be done like that.
Catalyst version is 19.11.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Automatic Mixed Precision package - torch.amp - PyTorch
torch.amp provides convenience methods for mixed precision, ... Creates model and optimizer in default precision model = Net().cuda() optimizer = optim.
Read more >How to Optimize Data Transfers in CUDA C/C++
In this and the following post we begin our discussion of code optimization with how to efficiently transfer data between the host and...
Read more >RuntimeError: Input type (torch.FloatTensor) and weight type ...
You get this error because your model is on the GPU, but your data is on the CPU. So, you need to send...
Read more >Efficient Training on a Single GPU - Hugging Face
from_pretrained("bert-large-uncased").to("cuda") >>> print_gpu_utilization() GPU memory occupied: 2631 MB. We can see that the model weights alone take up 1.3 ...
Read more >Trainer — PyTorch Lightning 1.8.5.post0 documentation
This might be useful if you want to collect new metrics from a model right at its ... If your machine has GPUs,...
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
@Yorko try now with
19.11.1
pleaseLooks like it’s fine now, same Kernel, 11th version. Closing.