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

Use new-style autograd function with static forward method. #63

Open
kevinzezel opened this issue May 5, 2020 · 6 comments
Open

Use new-style autograd function with static forward method. #63

kevinzezel opened this issue May 5, 2020 · 6 comments

Comments

@kevinzezel
Copy link

HI, I got this error:

pytorch==1.4.0
torchvision==0.2.1

loading pretrained resnet model
Finished loading model!
demo.py:94: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
x = Variable(x.unsqueeze(0) , volatile=True)
/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:2416: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:2506: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))
/home/kzezel/Kevin Zezel Gomes/FaceDetection-DSFD/face_ssd.py:187: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
prior = Variable( priorbox.forward() , volatile=True)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
Traceback (most recent call last):
File "demo.py", line 250, in
test_oneimage()
File "demo.py", line 245, in test_oneimage
det = bbox_vote(det)
File "demo.py", line 69, in bbox_vote
det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], axis=0) / np.sum(det_accu[:, -1:])
File "/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 398, in rdiv
return self.reciprocal() * other
File "/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 486, in array
return self.numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

@chixiangw
Copy link

Hi Kevin, how did you resolve this error? I have exactly the same problem.

@liuleiBUAA
Copy link

Hi Kevin, how did you resolve this error? I have exactly the same problem.

Me too

@hourieh77
Copy link

Hi Kevin, how did you resolve this error? I have exactly the same problem.

me too... :(

@liuleiBUAA
Copy link

liuleiBUAA commented Jul 22, 2021 via email

@gkrisp98
Copy link

I am facing the same proble, has anyone figured it out ?

@OceanWong1991
Copy link

@gkrisp98
change face_ssd.py line 345 to:

         # output = self.detect(
               #   face_loc.view(face_loc.size(0), -1, 4),         # loc preds
               #   self.softmax(face_conf.view(face_conf.size(0), -1, self.num_classes)), # conf preds
               #   self.priors.type(type(x.data))                  # default boxes
               # )

               ###########################################################修改代码################################################################
               # Detect类不支持静态方法的前向传播,因此使用类直接调用方法
               output = self.detect.forward(face_loc.view(face_loc.size(0), -1, 4),
                                            self.softmax(face_conf.view(face_conf.size(0), -1, self.num_classes)),
                                            self.priors.type(type(x.data)))
               ###########################################################修改代码################################################################

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

6 participants