RuntimeError: rINTERNAL ASSERT FAILED at "/media/nvidia/NVME/pytorch/pytorch-v1.9.0/aten/src/ATen/core/jit_type_base.h":184, please report a bug to PyTorch

I am trying to convert pytorch (.pth) to ONNX for tensorRT. I receive this error.

Could you post a minimal, executable code snippet which would reproduce the issue in the latest release, please?

from pathlib import Path
import numpy as np
import torch.onnx
from yolov3.utils import utils as utils
from yolov3.models.yolov3 import YOLOv3

config_path = Path( “yolov3_custom.yaml”)
model_path = Path(“yolov3_007000.pth”)
batch_size = 1
config1 = utils.load_config(config_path)

def create_model(config, weights_path=None):
# モデルを作成する。
if config[“model”][“name”] == “yolov3”:
model = YOLOv3(config[“model”])

# 重みを読み込む。
if weights_path.suffix == ".pth":
    state = torch.load(weights_path, map_location=lambda storage, loc: storage.cuda(0))
    model.load_state_dict(state["model_state_dict"])
    print(f"state_dict format weights file loaded. {weights_path}")

return model

torch_model = create_model(config1, model_path)
torch_model.eval()
x = torch.randn(batch_size, 3, 320, 320, requires_grad=True)
torch_out = torch_model(x)

torch.onnx.export( torch_model,
x,
“model.onnx”,
export_params=True,
opset_version=12,
do_constant_folding=True,
input_names = [‘input’],
output_names = [‘output’],
dynamic_axes = {‘input’ : {0: ‘batch_size’},
‘output’: {0: ‘batch_size’}}
)

I am using Jetson AGX Xavier jetpack 4.6 Ubuntu 18.04

/media/toyota/9C33-6BBD/hito_line_TensorRT/yolov3/models/yolo_layer.py:122: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
anchors = torch.tensor(self.anchors, dtype=x.dtype, device=x.device)
/media/toyota/9C33-6BBD/hito_line_TensorRT/yolov3/models/yolo_layer.py:123: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
all_anchors = torch.tensor(self.all_anchors, dtype=x.dtype, device=x.device)
Traceback (most recent call last):
File “convertONNX.py”, line 43, in
‘output’: {0: ‘batch_size’}}
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/init.py”, line 280, in export
custom_opsets, enable_onnx_checker, use_external_data_format)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 94, in export
use_external_data_format=use_external_data_format)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 695, in _export
dynamic_axes=dynamic_axes)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 467, in _model_to_graph
module=module)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 200, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/init.py”, line 313, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 971, in _run_symbolic_function
return torch._C._jit_onnx_convert_pattern_from_subblock(block, n, env)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/init.py”, line 313, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/utils.py”, line 994, in run_symbolic_function
return symbolic_fn(g, *inputs, **attrs)
File “/home/toyota/.local/lib/python3.6/site-packages/torch/onnx/symbolic_opset11.py”, line 101, in index_put
if indices_list[idx
].type().scalarType() == ‘Bool’:
RuntimeError: rINTERNAL ASSERT FAILED at “/media/nvidia/NVME/pytorch/pytorch-v1.9.0/aten/src/ATen/core/jit_type_base.h”:184, please report a bug to PyTorch.

This is the Full error message

hi, I get the same error, did you solve it? :sweat_smile: