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
RuntimeError: derivative for grid_sampler_2d_backward is not implemented #34704
Comments
Hello, Best regards |
@Fuggy I am running into this issue as well :( Have you found a solution to this? |
Hello @lucidrains. Best of lucks, |
Hello, I got the same issue. Any solution? |
Is this issue closed because of experimental jacobian and hessian API? |
Getting the same issue "RuntimeError: derivative for grid_sampler_2d_backward is not implemented" when using torch::nn::functional::grid_sample with torch.autograd.grad. Any workaround? |
I got the same issue,
Any solution? |
Any updates on this? I'm having the same issue. |
@xieshuqin @YuliangXiu @pedrovfigueiredo |
@BaldrLector |
Dear @xieshuqin that you for sharing your experience. Do you remember how to register this function, so it can be set to zero? |
@AliaksandrSiarohin Sorry I don't remember that. You can clone the PyTorch source code and use IDE(e.g. VSCode) to find where the function is being used, that should save you some time on finding the correct file. Another alternative is to create a custom GridSample Function/Op and use it in your code. |
Got it, thanks, I rewrite the bilinear-sample with pytorch, now it can compute the second-order gradient. the code:
|
@BaldrLector I guess this line is not correct p = pff * dff + pfc + dfc + pcf + dcf + pcc + dcc. Here is mine implimentation if you interested:
|
@AliaksandrSiarohin You are right, and thanks for your code :) |
Hey @AliaksandrSiarohin and @BaldrLector In what exact archive did you change: def grid_sample. ??? help pls I have the same Runtime error. Hope you answer |
Hi, @JavierCoronaA01023063 I just use the new function of @AliaksandrSiarohin to replace the official grid_sample. |
Hi, @AliaksandrSiarohin i achieve a grid sample function for 3d following your code. the output is inconsistent with F.grid_sample, and i have no idea where is error.
|
Here is my implementation if you are interested. @vincenthesiyuan
|
Reopening due to users activity |
+1 I have the same issue wit torch 1.10.0 |
RuntimeError: derivative for aten::grid_sampler_2d_backward is not implemented |
Similar issue. How should I workaround? |
Same issue |
same issue |
Same issue |
same issue |
1 similar comment
same issue |
Hi everyone, |
thanks @cocoakang |
@NIRVANALAN Thank you! |
same issue for 3d |
sample issue for 3d "RuntimeError: derivative for aten::grid_sampler_3d_backward is not implemented" |
@linye-boli hi~ Same issue for me. Have your problem been solved? Asking for your help! |
Here is the cuda-based implementation with second order derivative https://github.com/AliaksandrSiarohin/cuda-gridsample-grad2. As far as I understand the style-gan grad_fix implementation assumes that the derivative wrp to grid is always zero, which makes sense if the grid is constant, however when the grid is predicted it will be incorrect. So this implementation should be more complete. Tell me if you find any problems with it. |
Has anyone tested this code on DDP? |
If AliaksandrSiarohin implementation crashes for you, add this line at the beginning: |
Same issue on pytorch version '2.0.1+cu117'. |
I want to use https://github.com/facebookresearch/jacobian_regularizer but I encounter these errors:
I am on torch '2.1.1+cu121' |
I solved this issue by update this two files in folder ..torch_utils\ops\ , conv2d_gradfix.py & grid_sample_gradfix.py |
hello, I have the same question. I want to know, how did you solve it. Thank you very much. |
where to write this code |
Any fix, or update on this issue? Trying to get StyleGAN2 to work again in CoLab and this error stops it from training..
|
Hi
When trying to compute the second order derivative of
grid_sampler
, the following error occurs:RuntimeError: derivative for grid_sampler_2d_backward is not implemented
.It seems useful to support second order derivative for bilinear interpolation operations like this, given bilinear interpolation is used in some common operations like deformable convs and roialign.
Another side question is that, if I write a custom operation in cuda, do I need to write a function by myself to support second order derivative of that operation? For example, the deformable conv operation in mmdet has its own cuda implementation (see here), is it possible to get the second order derivative of this operation without having to write my own implementation.
Thanks a lot
The text was updated successfully, but these errors were encountered: