xi11xi19 / centernet2torchscript Goto Github PK
View Code? Open in Web Editor NEWcenternet pytorch model to torch script model
License: BSD 3-Clause "New" or "Revised" License
centernet pytorch model to torch script model
License: BSD 3-Clause "New" or "Revised" License
I try to compile dcn_v2_cuda_forward_v2, here is my specs:
CUDA Version: 10.1
PyTorch Version: 1.4
Operating System: Ubuntu 18.04
GPU: GTX1050m
I got error
candidate: constexpr torch::jit::RegisterOperators::RegisterOperators(torch::jit::RegisterOperators&&)
/usr/lib/libtorch_abi11_14/include/torch/csrc/jit/custom_operator.h:16:18: note: candidate expects 1 argument, 2 provided
CMakeFiles/dcn_v2_cuda_forward_v2.dir/build.make:1509: recipe for target 'CMakeFiles/dcn_v2_cuda_forward_v2.dir/vision.cpp.o' faile
thanks for you work,I failed as follows,
traced_script_module = torch.jit.trace(model, example)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 882, in trace
check_tolerance, _force_outplace, _module_class)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1028, in trace_module
module = make_module(mod, _module_class, _compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1836, in init
tmp_module._modules[name] = make_module(submodule, TracedModule, _compilation_unit=None)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1836, in init
tmp_module._modules[name] = make_module(submodule, TracedModule, _compilation_unit=None)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1836, in init
tmp_module._modules[name] = make_module(submodule, TracedModule, _compilation_unit=None)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1836, in init
tmp_module._modules[name] = make_module(submodule, TracedModule, _compilation_unit=None)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1836, in init
tmp_module._modules[name] = make_module(submodule, TracedModule, _compilation_unit=None)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 727, in make_module
return _module_class(mod, _compilation_unit=_compilation_unit)
File "/root/anaconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1809, in init
assert(isinstance(orig, torch.nn.Module))
AssertionError
ValueError: Auto nesting doesn't know how to process an input object of type int. Accepted types: Tensors, or lists/tuples of them
在pytorch1.1 cuda10上是可以的,但是在pytorch1.0 cuda8上面就报上面的错误。trace的时候
traced_script_module = torch.jit.trace(self.dla, x)
Hi, xi11xi19:
I used your sample code and tried to convert dla34 model to pt file, but it will output below abnormal message:
D:\ML\C\CenterNet2TorchScript-master\DCNv2\dcn_v2.py:93: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
self.deformable_groups)
Could you help to support this problem?
Thanks a lot.
Hi folks,
ubuntu 16.04+cuda11.0+pytorch1.7.1, I can not compile this repository, so I download lbin's DCNv2, https://github.com/lbin/DCNv2
Add modified some file acc. to this repository, such as add dcn_v2_cuda_forward_v2 in dcn_v2_cuda.cu and accordingly in vision.h, add keep vision.cpp the same as this repository
And I got this error when run make.sh
/vision.cpp:5:5: error: ‘RegisterOperators’ is not a member of ‘torch::jit’
torch::jit::RegisterOperators("my_ops::dcn_v2_cuda_forward_v2", &dcn_v2_cuda_forward_v2);
looks like pytorch 1.7.1 not support torch::jit::registerOperators
So which func in torch1.7.1 can take place of torch::jit::registerOperators?
Any help will be appreciated!
Hi, I'm able to compile https://github.com/CharlesShang/DCNv2 fine, but when I try to compile this version I get the following error:
DCNv2/src/vision.cpp:12:92: error: no matching function for call to \u2018torch::jit::RegisterOperators::RegisterOperators(const char [31], at::Tensor (*)(const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t))\u2019
torch::jit::RegisterOperators("my_ops::dcn_v2_cuda_forward_v2", &dcn_v2_cuda_forward_v2);
^
In file included from /usr/local/lib/python3.7/dist-packages/torch/include/torch/script.h:6:0,
from /CenterTrack/src/lib/model/networks/DCNv2/src/vision.cpp:3:
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:20:3: note: candidate: torch::jit::RegisterOperators::RegisterOperators(std::vector<torch::jit::Operator>)
RegisterOperators(std::vector<Operator> operators) {
^~~~~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:20:3: note: candidate expects 1 argument, 2 provided
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:17:3: note: candidate: constexpr torch::jit::RegisterOperators::RegisterOperators()
RegisterOperators() = default;
^~~~~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:17:3: note: candidate expects 0 arguments, 2 provided
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:16:18: note: candidate: constexpr torch::jit::RegisterOperators::RegisterOperators(const torch::jit::RegisterOperators&)
struct TORCH_API RegisterOperators {
^~~~~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:16:18: note: candidate expects 1 argument, 2 provided
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:16:18: note: candidate: constexpr torch::jit::RegisterOperators::RegisterOperators(torch::jit::RegisterOperators&&)
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/jit/custom_operator.h:16:18: note: candidate expects 1 argument, 2 provided
/CenterTrack/src/lib/model/networks/DCNv2/src/vision.cpp:11:13: warning: \u2018registry\u2019 defined but not used [-Wunused-variable]
static auto registry =
^~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Happen to know how I can solve this?
Edit: should this be compatible with torch 1.4.0?
I think for later versions in src/vision.cpp torch::jit::RegisterOperator() should change to torch::RegisterOperators()
hi xi11xi19,
i use your code and had convert .pth to .pt
then i want to test the .pt file, use :
module = torch::jit::load()
to load this model, i met this error:
terminate called after throwing an instance of 'torch::jit::script::ErrorReport'
what():
Unknown builtin op: my_ops::dcn_v2_cuda_forward_v2.
Could not find any similar ops to my_ops::dcn_v2_cuda_forward_v2. This op may not exist or may not be currently supported in TorchScript.
can i get some help, thanks
有什么办法能确认用trace script工具生成的pt模型 和python的pth模型是一致的吗
我现在转完模型后 发现在c++中forward的结果 和python 不一致
已经确认了输入是相同的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.