xy-guo / GwcNet

Group-wise Correlation Stereo Network, CVPR 2019
MIT License
322 stars 60 forks source link

train using Pytorch1.8.0 #27

Open rebecca0011 opened 2 years ago

rebecca0011 commented 2 years ago

I am a freshman. I use Pytorch1.8.0 but got this error, but do not know how to fix... Traceback (most recent call last): File "main.py", line 201, in <module> train() File "main.py", line 101, in train loss, scalar_outputs, image_outputs = train_sample(sample, compute_metrics=do_summary) File "main.py", line 159, in train_sample image_outputs["errormap"] = [disp_error_image_func()(disp_est, disp_gt) for disp_est in disp_ests] File "main.py", line 159, in <listcomp> image_outputs["errormap"] = [disp_error_image_func()(disp_est, disp_gt) for disp_est in disp_ests] File "/home/rc/anaconda3/envs/DL/lib/python3.7/site-packages/torch/autograd/function.py", line 262, in __call__ "Legacy autograd function with non-static forward method is deprecated. " 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)

yuankang1234 commented 2 years ago

我也是这个问题,请问你解决没?

binghui10086 commented 2 years ago

我也是这个问题,请问有解决的吗

zjwfcl commented 1 year ago

你好 这个问题最后得到解决了吗

S1aoXuan commented 4 months ago

I solve this problem, and the code works in pytorch 1.13.0. Here is my solution.

  1. go to utils/visualization.py. In class disp_error_image_func, add @staticmethod before forward and backward function
  2. go to main.py. change [disp_error_image_func()(disp_est, disp_gt) for disp_est in disp_ests] to [disp_error_image_func().apply(disp_est, disp_gt) for disp_est in disp_ests] in test_sample and train_sample function

But I don't know if this modification will affect the final result.