Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False.
时间: 2023-09-28 11:06:44 浏览: 199
回答: 该错误提示表示尝试在CUDA设备上反序列化对象,但torch.cuda.is_available()返回False,即没有可用的CUDA设备。要解决这个问题,可以使用torch.load函数时添加参数map_location=torch.device('cpu'),将存储映射到CPU上。这样可以确保在没有CUDA设备的CPU-only机器上正常加载对象。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [pytorch出错: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False](https://blog.csdn.net/qq_27149279/article/details/106037681)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* *3* [RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is Fal](https://blog.csdn.net/qq_44936246/article/details/126375749)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文