在Linux上使用libtorch时报错:
terminate called after throwing an instance of 'c10::Error'
what(): isTuple()INTERNAL ASSERT FAILED at ../aten/src/ATen/core/ivalue_inl.h:1400
出错语句为
...
torch::jit::script::Module model_high;
output = model_high.forward(inputs).toTensor();
...
版本:
libtorch 1.9.0
CUDA 10.2
已解决。
解决方法:保证pytorch与lintorch版本一致即可
该回答引用ChatGPT
这个错误通常是由于使用不兼容版本的libtorch和CUDA引起的。请确保你的CUDA版本与你所下载的libtorch版本匹配。在你的情况下,你使用的是libtorch 1.9.0和CUDA 10.2。
此外,还有可能是输入的数据类型与模型期望的数据类型不匹配。请检查输入数据的维度和类型是否与模型期望的一致。
你看见你的错误信息没有,将libtorch中的IValue类型转换为Tensor类型时出现的错误。
建议你先检查IValue类型是否正确,并确保它可以被正确转换为Tensor类型。之后在跑一次