我是靠谱客的博主 怕黑乌冬面,这篇文章主要介绍将gpu并行模型转换为单cpu/gpu模型,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import torch def convert_model(para_model,single_model): checkpoint = torch.load(para_model ,map_location=torch.device("cpu")) output={} for key,value in checkpoint['model'].items(): output[key.lstrip("module.")]=value torch.save({'model':output},single_model) if __name__=="__main__": convert_model(para_model="model_2.pth", single_model="model.pth")

最后

以上就是怕黑乌冬面最近收集整理的关于将gpu并行模型转换为单cpu/gpu模型的全部内容,更多相关将gpu并行模型转换为单cpu/gpu模型内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部