CenterNet
CenterNet copied to clipboard
How to deploy in C++ Frontend
I'm using CUDA9 and Pytorch 1.0,and refer to this: princeton-vl/CornerNet@3809432. And delete all the compiled files before recompiling the corner pooling layers. Then solve question:top_pool.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN2at6detail20DynamicCUDAInterface10set_deviceE
I refer to the following example, I hope to get model.pt:
import torch import torchvision model = torchvision.models.resnet18() example = torch.rand(1, 3, 224, 224) traced_script_module = torch.jit.trace(model, example)
and Modify code:
nnet = NetworkFactory() nnet.load_params_file("CenterNet-104_480000.pkl") nnet.model.eval() nnet.model.cuda() example = torch.rand(1,3,511,511).cuda() traced_script_module = torch.jit.trace(nnet.model,example) traced_script_module.save("torch_script_eval.pt")
but
Traceback (most recent call last): File "inference.py", line 192, in <module> function() File "inference.py", line 88, in function traced_script_module = torch.jit.trace(nnet.model,example) File "/home/xht04/anaconda3/envs/pt/lib/python3.6/site-packages/torch/jit/__init__.py", line 688, in trace var_lookup_fn, _force_outplace) File "/home/xht04/anaconda3/envs/pt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__ result = self._slow_forward(*input, **kwargs) File "/home/xht04/anaconda3/envs/pt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 481, in _slow_forward result = self.forward(*input, **kwargs) File "/home/xht04/CenterNet-1/nnet/py_factory.py", line 32, in forward return self.module(*xs, **kwargs) File "/home/xht04/anaconda3/envs/pt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__ result = self._slow_forward(*input, **kwargs) File "/home/xht04/anaconda3/envs/pt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 481, in _slow_forward result = self.forward(*input, **kwargs) File "/home/xht04/CenterNet-1/models/py_utils/kp.py", line 295, in forward return self._test(*xs, **kwargs) File "/home/xht04/CenterNet-1/models/py_utils/kp.py", line 290, in _test return self._decode(*outs[-8:], **kwargs) File "/home/xht04/CenterNet-1/models/py_utils/kp_utils.py", line 91, in _decode tl_scores, tl_inds, tl_clses, tl_ys, tl_xs = _topk(tl_heat, K=K) File "/home/xht04/CenterNet-1/models/py_utils/kp_utils.py", line 71, in _topk topk_inds = topk_inds % (height * width) RuntimeError: Expected object of backend CUDA but got backend CPU for argument #2 'other'
How can I modify it?
Thanks