Strongly typed engine returns NaN for every depth output on sm_120 (TRT 11.4); onnxruntime on the same ONNX matches PyTorch

未关闭
#4,926 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

Start by requesting the shareable random-weight ONNX export and input/output NPZ, then run the supplied strongly typed TensorRT reproduction and compare its outputs with ONNX Runtime. Use the reported intermediate-tensor output experiment to narrow the faulty fused region; the issue names no source files or tests to start from. Done means TensorRT produces finite depth and sky outputs consistent with ONNX Runtime and PyTorch.

由索引模型根据 Issue 内容生成。

描述

Module:ONNX

Description

A strongly typed engine built from an ONNX export of MVSAnywhere (multi-view depth: reference image, source images, intrinsics and poses; 448x672, fixed shapes) builds without warnings in 140 s but returns NaN for every element of its depth and sky outputs. onnxruntime 1.32.0 (CPU) on the same file matches PyTorch eager (max abs error 0.010 on depths in 0.27..0.31). The fp32 export behaves the same way (all NaN).

TensorRT:

build: ok in 140 s
output depth (1, 448, 672) float32: nan fraction 1.000
output mask (1, 448, 672) bool: all 0
output sky (1, 448, 672) float32: nan fraction 1.000
output depth_range (1, 2) float32: -0.0825, 0.6475

onnxruntime, same file and inputs:

depth (1, 448, 672): nan fraction 0.000, range 0.271..0.315
mask: all 1
sky: range 1.2e-07..0.075
depth_range: 0.259, 0.630

depth_range shows where it goes wrong: TensorRT returns a negative minimum depth, and the log / sqrt of that range downstream turns the depth map into NaN. The coarse first-stage depth inside the engine is 0.998 everywhere instead of 0.30..0.53. With about 60 intermediate tensors marked as network outputs the engine is finite and correct; with 4 of them it is NaN again, so the problem is in a fused region, not a single op.

The same happens with the weights replaced by random values (seed 0): TensorRT again returns depth_range -0.0825, 0.649 and NaN depths, onnxruntime 0.340, 0.567 and finite depths matching eager. So the wrong value does not depend on the weights, and that random-weight file can be shared freely.

Environment

TensorRT 11.4.0.106 (tensorrt-cu13 wheel, current release), RTX 5060 Ti 16 GB (sm_120), driver 595.99.02, CUDA 13.0, Ubuntu 26.04, Python 3.12. ONNX: torch 2.14.1 dynamo exporter, opset 18, fp16 weights, onnx 1.23.2.

Relevant Files

The ONNX file is 407 MB, above the attachment limit; I can share the random-weight export plus the input/output npz on request (or via a link if you tell me where).

Steps To Reproduce

import tensorrt as trt
logger = trt.Logger(trt.Logger.WARNING)
builder = trt.Builder(logger)
network = builder.create_network(1 << int(trt.NetworkDefinitionCreationFlag.STRONGLY_TYPED))
parser = trt.OnnxParser(network, logger)
assert parser.parse_from_file("mvsanywhere_448x672_fp16.onnx")
plan = builder.build_serialized_network(network, builder.create_builder_config())
# deserialize, bind the npz inputs, execute_async_v3: depth and sky are all NaN

Expected: finite depths, as onnxruntime and PyTorch give. Actual: NaN everywhere, no builder warning.

主要语言
C++
星标
13.5k
派生
2.4k
平均合并
6 天 21 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/TensorRT 的其他 Issue

查看 NVIDIA/TensorRT 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。