打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
使用官方提供的pytorch的云开发环境把自己的模型转成离线模型时出现报错
报错信息如下:
File "/networks/backbones/ResNetvd.py", line 201, in forward
x = self.conv1(x)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 539, in __call__
result = self._slow_forward(*input, **kwargs)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 525, in _slow_forward
result = self.forward(*input, **kwargs)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/container.py", line 92, in forward
input = module(input)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 539, in __call__
result = self._slow_forward(*input, **kwargs)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 525, in _slow_forward
result = self.forward(*input, **kwargs)
File "/home/PytorchOCR-master/torchocr/networks/backbones/DetResNetvd.py", line 29, in forward
x = self.conv(x)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 539, in __call__
result = self._slow_forward(*input, **kwargs)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 525, in _slow_forward
result = self.forward(*input, **kwargs)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/conv.py", line 345, in forward
return self.conv2d_forward(input, self.weight)
File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/conv.py", line 342, in conv2d_forward
self.padding, self.dilation, self.groups)
RuntimeError: To do for CPU
导出离线模型的代码如下:
model = build_model(cfg[]) state_dict = {} kv ckpt[].items(): state_dict[k.replace()] = v model.load_state_dict(state_dict) device = torch.device() model.eval() torch_mlu torch_mlu.core.mlu_model ctnet = model.float() example_mlu = torch.randn(=torch.float) randn_mlu = torch.randn(=torch.float) ct.set_core_number() ct.set_core_version() ct.set_device(-) ct.save_as_cambricon(model_name) net_traced = torch.jit.trace(net.to(ct.mlu_device())randn_mlu.to(ct.mlu_device())=) net_traced(example_mlu.to(ct.mlu_device())) ct.save_as_cambricon()
热门帖子
精华帖子