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

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead. #1021

Open
Lss6666 opened this issue Apr 15, 2022 · 2 comments

Comments

@Lss6666
Copy link

Lss6666 commented Apr 15, 2022

各位好友们:
我想用HICO数据集重新训练ResNet50 - dcn网络(人体关键点136个)。
但是当我运行python /data/open_mmlab/frames/AlphaPose/scripts/train.py --cfg /data/open_mmlab/frames/AlphaPose/configs/halpe_136/resnet/256x192_res50_lr1e-3_2x-dcn-combined.yaml时,出现以下问题:
Traceback (most recent call last):
File "/data/open_mmlab/frames/AlphaPose/scripts/train.py", line 345, in
main()
File "/data/open_mmlab/frames/AlphaPose/scripts/train.py", line 292, in main
loss, miou = train(opt, train_loader, m, criterion, optimizer, writer)
File "/data/open_mmlab/frames/AlphaPose/scripts/train.py", line 96, in train
loss.backward()
File "/workspace/miniconda3/envs/alps/lib/python3.7/site-packages/torch/tensor.py", line 221, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/workspace/miniconda3/envs/alps/lib/python3.7/site-packages/torch/autograd/init.py", line 132, in backward
allow_unreachable=True) # allow_unreachable flag
File "/workspace/miniconda3/envs/alps/lib/python3.7/site-packages/torch/autograd/function.py", line 89, in apply
return self._forward_cls.backward(self, *args) # type: ignore
File "/workspace/miniconda3/envs/alps/lib/python3.7/site-packages/torch/autograd/function.py", line 210, in wrapper
outputs = fn(ctx, *args)
File "/data/open_mmlab/frames/AlphaPose/alphapose/models/layers/dcn/deform_conv.py", line 110, in backward
cur_im2col_step)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
有一种解决方式是根据cezannec/capsule_net_pytorch#4
找出view()这个函数,在前面用上. reshape or a call to .contiguous()
但是deform_conv_cuda.cpp中的view()函数很多,不知道从何下手。
希望能和大家一起讨论交流,谢谢各位的解答!

@tonyskypc
Copy link

我将这个函数的所有view替换成reshape,重新编译安装,就可以了,你尝试一下。

@CosmosView
Copy link

我将这个函数的所有view替换成reshape,重新编译安装,就可以了,你尝试一下。

Nice work! Thanks a lot!

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

3 participants