怎么解决下面这个BUG“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.”
时间: 2023-06-04 21:02:58 浏览: 108
torch.cuda.is-available()返回False的问题解决
该 BUG 的解决方法是,在加载模型时使用 map_location=torch.device('cpu') 参数,将模型加载到 CPU 上。例如:
```python
model = torch.load('model.pt', map_location=torch.device('cpu'))
```
阅读全文