运行的时候不报错,但是打包以后,由于调用了pytorch,所以报了如下错误
torch\_jit_internal.py:750: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000012D8ED93310>.
warnings.warn(f"Unable to retrieve source for @torch.jit._overload function: {func}.")
torch\_jit_internal.py:750: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000012D8ED

博客讨论了在打包包含PyTorch的项目时遇到的UserWarning问题。尽管程序能够正常运行,但控制台显示多个关于无法检索到torch.jit._overload_function源代码的警告。两种解决方法被提出:1) 打包时添加--hidden-import=torch.jit,但未生效;2) 注释掉torch_jit_internal.py中的特定警告语句。虽然这不是错误,但影响日志整洁。作者建议通过注释警告来清理控制台输出。
最低0.47元/天 解锁文章
497





