lucasjinreal / DCNv2_latest

DCNv2 supports decent pytorch such as torch 1.5+ (now 1.8+)
BSD 3-Clause "New" or "Revised" License
626 stars 124 forks source link

Error when compiling: 'TORCH_CHECK_ARG' was not declared in this scope #50

Open AlpAcA0072 opened 2 years ago

AlpAcA0072 commented 2 years ago

Hi, My environment is PyTorch 1.8.1+cu101 and CUDA 10.1. When I compiled DCNv2, an error was encounted:

/DCNv2_latest/src/cpu/dcn_v2_cpu.cpp: In function 'std::vector<at::Tensor> dcn_v2_cpu_backward(const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, int, int, int, int, int, int, int, int, int)':
/DCNv2_latest/src/cpu/dcn_v2_cpu.cpp:141:5: error: 'TORCH_CHECK_ARG' was not declared in this scope
     TORCH_CHECK_ARG(input.is_contiguous(), 1, "input tensor has to be contiguous");
     ^~~~~~~~~~~~~~~
/DCNv2_latest/src/cpu/dcn_v2_cpu.cpp:141:5: note: suggested alternative: 'TORCH_CHECK_MSG'
     TORCH_CHECK_ARG(input.is_contiguous(), 1, "input tensor has to be contiguous");
     ^~~~~~~~~~~~~~~
     TORCH_CHECK_MSG

I wonder how to solve this problem. Thanks a lot.

Natsu-Akatsuki commented 2 years ago

According to the latest README.md. Try to checkout the last commit. e.g


git checkout fa9b2fd740ced2a22e0e7e913c3bf3934fd08098
bodhiyang commented 2 years ago

i encountered the same problem. do u figure it out now?

hongyujinhongyu commented 2 years ago

I encountered the same. Still no clue to solve


error: 'TORCH_CHECK_ARG' was not declared in this scope
TORCH_CHECK_ARG(input.is_contiguous(), 1, "input tensor has to be contiguous");
........
........
/{my_prokect_dir}/src/lib/models/networks/DCNv2_latest-master/src/cpu/dcn_v2_cpu.cpp:235:65: warning: 'T* at::Tensor::data() const [with T = float]' is deprecated: Tensor.data() is deprecated. Please use Tensor.data_ptr() instead. [-Wdeprecated-declarations]
columns.data<scalar_t>());
^
In file included from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/Tensor.h:3:0,
from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/Context.h:4,
from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/ATen.h:9,
from /data/aif/hongyu/may_compare_task/centernet/centernet-master/src/lib/models/networks/DCNv2_latest-master/src/cpu/dcn_v2_cpu.cpp:4:
/usr/local/lib/python3.6/dist-packages/torch/include/ATen/core/TensorBody.h:395:7: note: declared here
T * data() const {
^
error: command 'g++' failed with exit status 1

                                                                              ^
fly2skyToEnjoy commented 2 years ago

You are Good! @Natsu-Akatsuki

pure19990902 commented 2 years ago

I encountered the same problem. Do you figure it out now?

AlpAcA0072 commented 2 years ago

One possible solution to the error is to downgrade PyTorch to version 1.6.x. This problem may be caused by incompatible versions of DCNV2 with PyTorch.