Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcn compile errors #84

Closed
bitnom opened this issue May 28, 2020 · 4 comments
Closed

dcn compile errors #84

bitnom opened this issue May 28, 2020 · 4 comments

Comments

@bitnom
Copy link

bitnom commented May 28, 2020

Trying to compile dcn with python setup.py develop produces:

src/deform_conv_cuda.cpp: In function ‘void shape_check(at::Tensor, at::Tensor, at::Tensor*, at::Tensor, int, int, int, int, int, int, int, int, int, int)’:
src/deform_conv_cuda.cpp:65:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK(weight.ndimension() == 4,
   ^~~~~~~~
src/deform_conv_cuda.cpp:65:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK(weight.ndimension() == 4,
   ^~~~~~~~
   DCHECK
src/deform_conv_cuda.cpp: In function ‘int deform_conv_forward_cuda(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, int)’:
src/deform_conv_cuda.cpp:192:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK((offset.size(0) == batchSize), "invalid batch size of offset");
   ^~~~~~~~
src/deform_conv_cuda.cpp:192:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK((offset.size(0) == batchSize), "invalid batch size of offset");
   ^~~~~~~~
   DCHECK
src/deform_conv_cuda.cpp: In function ‘int deform_conv_backward_input_cuda(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, int)’:
src/deform_conv_cuda.cpp:298:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK((offset.size(0) == batchSize), 3, "invalid batch size of offset");
   ^~~~~~~~
src/deform_conv_cuda.cpp:298:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK((offset.size(0) == batchSize), 3, "invalid batch size of offset");
   ^~~~~~~~
   DCHECK
src/deform_conv_cuda.cpp: In function ‘int deform_conv_backward_parameters_cuda(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, float, int)’:
src/deform_conv_cuda.cpp:413:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK((offset.size(0) == batchSize), "invalid batch size of offset");
   ^~~~~~~~
src/deform_conv_cuda.cpp:413:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK((offset.size(0) == batchSize), "invalid batch size of offset");
   ^~~~~~~~
   DCHECK
src/deform_conv_cuda.cpp: In function ‘void modulated_deform_conv_cuda_forward(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, bool)’:
src/deform_conv_cuda.cpp:493:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK(input.is_contiguous(), "input tensor has to be contiguous");
   ^~~~~~~~
src/deform_conv_cuda.cpp:493:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK(input.is_contiguous(), "input tensor has to be contiguous");
   ^~~~~~~~
   DCHECK
src/deform_conv_cuda.cpp: In function ‘void modulated_deform_conv_cuda_backward(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, bool)’:
src/deform_conv_cuda.cpp:574:3: error: ‘AT_CHECK’ was not declared in this scope
   AT_CHECK(input.is_contiguous(), "input tensor has to be contiguous");
   ^~~~~~~~
src/deform_conv_cuda.cpp:574:3: note: suggested alternative: ‘DCHECK’
   AT_CHECK(input.is_contiguous(), "input tensor has to be contiguous");
   ^~~~~~~~
   DCHECK
error: command 'gcc' failed with exit status 1
@ryul99
Copy link

ryul99 commented Jun 1, 2020

If you are using pytorch 1.5, I think this solution can solve your problem
xinntao/EDVR#146 (comment)

@dmmartindale
Copy link

Yes, the problem is that mmsr has not been updated to support pytorch 1.5, which is what you get if you install pytorch via anaconda now.

There have been several reports of the same problem with the same source files in the mmdetection project; see issue #2513 in that project. This was fixed by releasing version 2.0 of mmdetection; see issue #2618 and 2619. If you look at the revision history of the files deform_conv_cuda.cpp and deform_conv_cuda_kernel.cu in the master branch of mmdetection, you can see what was changed in version 2.0.

You cannot simply copy the two source files from mmdetection source tree into mmsr's source directory; there are a few differences between the files. Instead, you can either do a pair-wise compare of the two files and copy across only the relevant changes, or just hand-edit the source files within mmsr's source directory. The changes needed are:

In deform_conv_cuda.cpp, change all occurrences of AT_CHECK to TORCH_CHECK.

In deform_conv_cuda_kernel.cu, find all of the occurrences of
data_col.data
data_im.data
data_mask.data
data_offset.data
grad_im.data
grad_offset.data
grad_mask.data
and add the string "_ptr" to each. I.e. data_col.data becomes data_col.data_ptr.

In addition, there appears to be one bug in the second file that has been corrected in mmdetection. In line 821 of the source, an argument list includes "pad_h, pad_h" where mmdetection's version of the code passes "pad_h, pad_w". I changed this to agree with mmdetection.

With these changes, the dcn compile succeeds. (Ubuntu 18.04.4 LTS, GCC 7.5.0, Anaconda with Python 3.7.6, CUDA 10.1, Pytorch 1.5.

@dvdmc
Copy link

dvdmc commented Jun 26, 2020

It seems to compile for me. I hope they add this fix soon! Thanks for your work

Ubuntu 18.04.4 LTS, GCC 7.5.0, python 3.6.9, CUDA 11, Pytorch 1.5

@xinntao
Copy link
Collaborator

xinntao commented Jul 8, 2020

Thanks for using MMSR.
We will upgrade MMSR to MMEditing (in the same repo), which consists of SR, inpainting, matting and generation tasks.
And MMSR will be deprecated and no longer exist.
This feature will be updated in MMEditing.

@xinntao xinntao closed this as completed Jul 8, 2020
zengyh1900 pushed a commit that referenced this issue Dec 30, 2022
* [Feature] Support SwinIR model

* [Feature] Support SwinIR model

* [Feature] Support SwinIR model

* [Feature] Support SwinIR model

* [Feature] Support SwinIR model

* [Feature] Support SwinIR model

* fix configs

* rename

* remove testdata

* refactor decompression test config

* update the readme

* [Feature] Support SwinIR model

* update random JPEG and noise

* update random JPEG and noise

* update real sr large config

* fix sr configs

* fix car and denoising configs

* fix random_degradations

* fix readme

* refactor swinirnet

* fix ut

* remove files

* fix init

* fix jpeg comp

* fix readme

* fix lint

* fix ut

* fix ut

* fix ut

Co-authored-by: Z-Fran <1396925302@qq.com>
Co-authored-by: Z-Fran <49083766+Z-Fran@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants