simple-faster-rcnn-pytorch icon indicating copy to clipboard operation
simple-faster-rcnn-pytorch copied to clipboard

RuntimeError: Legacy autograd function with non-static forward method is deprecated.

Open amazingcodeLYL opened this issue 5 years ago • 5 comments
trafficstars

RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)

升级了torch和torchvision版本,又降低了torch和torchvision版本都不行 求解决办法

amazingcodeLYL avatar Apr 30 '20 14:04 amazingcodeLYL

遇到同样问题 怎么解决的?

MiaoRain avatar May 05 '20 20:05 MiaoRain

其实这个就是torch版本的问题, specify torchvision==0.4.0就可以解决

pip uninstall torchvision
pip uninstall torch
pip install torchvision==0.4.0

torchvision==0.4.0会自动安装1.2版本的pytorch,安装好之后重启一下environment就可以运行了

tobyatgithub avatar May 19 '20 04:05 tobyatgithub

感谢 tobyatgithub 的帮助

MiaoRain avatar May 25 '20 16:05 MiaoRain

I changed RoIPooling2D here to:

class RoIPooling2D(t.nn.Module):
    def __init__(self, outh, outw, spatial_scale):
        super(RoIPooling2D, self).__init__()
        self.outh, self.outw, self.spatial_scale = outh, outw, spatial_scale

    def forward(self, x, rois):
        return roi_pool(x, rois, (self.outh, self.outw), self.spatial_scale)

I also did from torchvision.ops import roi_pool in the same file. This looks to me solve the problem.

chensong1995 avatar Jun 20 '20 17:06 chensong1995

I changed RoIPooling2D here to:

class RoIPooling2D(t.nn.Module):
    def __init__(self, outh, outw, spatial_scale):
        super(RoIPooling2D, self).__init__()
        self.outh, self.outw, self.spatial_scale = outh, outw, spatial_scale

    def forward(self, x, rois):
        return roi_pool(x, rois, (self.outh, self.outw), self.spatial_scale)

I also did from torchvision.ops import roi_pool in the same file. This looks to me solve the problem.

Problem solved, thank you!

jiangsn avatar Jun 25 '20 13:06 jiangsn