来自 Pytorch 的"torch.relu_(input) unknown parameter type"



我正试图在GPU上的Google Colab中运行这个3D姿态估计repo,但在完成所有步骤并放入我自己的左/右摄像头视频后,我在Colab:中遇到了这个错误

infering thread started
1 1
: cannot connect to X server 
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/content/Stereo-3D-Pose-Estimation/poseinferscheduler.py", line 59, in infer_pose_loop
l_pose_t = infer_fast(self.net, l_img, height, self.stride, self.upsample_ratio, self.cpu)
File "/content/Stereo-3D-Pose-Estimation/pose3dmodules.py", line 47, in infer_fast
stages_output = net(tensor_img)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/content/Stereo-3D-Pose-Estimation/models/with_mobilenet.py", line 115, in forward
backbone_features = self.model(x)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py", line 139, in forward
input = module(input)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py", line 139, in forward
input = module(input)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/activation.py", line 102, in forward
return F.relu(input, inplace=self.inplace)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 1296, in relu
result = torch.relu_(input)
RuntimeError: unknown parameter type

我有点困惑,为什么我会看到它,我已经安装了所有必要的先决条件;也无法理解它的含义。

由于回溯发生在pytorch库中,我检查了pytorch github上的代码。

这个错误的意思是,您正在调用torch.relu中的一个就地激活函数到某个名为input的对象。然而,实际情况是torch后端无法识别输入类型,这就是为什么它是一个运行时错误。

因此,我建议打印出输入并运行

type(input)

以了解对象输入代表什么以及变量是什么。作为进一步的参考,这是Pytorch在后端运行的特定脚本,导致它抛出未知的参数类型错误。快速查看,它似乎是一个switch语句,用于确认值是否属于类型列表。如果它不在类型列表中,那么它将运行引发未知参数类型错误的默认块。

https://github.com/pytorch/pytorch/blob/aacc722aeca3de1aedd35adb41e6f8149bd656cd/torch/csrc/utils/python_arg_parser.cpp#L518-L541

编辑:

如果type(input(返回torch.ttensor,那么这可能是您使用的python版本的问题。我知道你说你有先决条件,但我认为最好仔细检查一下你是否有python 3.6,也许但最好是python 3.5或3.7。这些是python版本,适用于你刚刚发给我的回购。

您可以通过键入以下内容在collab上找到python版本CCD_ 1。请确保它返回您正在运行的软件支持的正确版本。这个错误可能是因为python本身在其后端表达了这个错误,而不是torch。

我发现这个stackoverflow很有用,因为它显示了一些代码如何无法识别python中的内置类型字典:;TypeError:未知参数类型:<类';dict_values'>quot;对此的解决方案是检查python版本。

Sarthak

相关内容

最新更新