# Segmentation fault when using TensorRT to compile a model

**URL:** <https://forums.developer.nvidia.com/t/segmentation-fault-when-using-tensorrt-to-compile-a-model/218872>\
**Category:** TensorRT\
**Created:** [June 27, 2022, 2:07am UTC](https://forums.developer.nvidia.com/t/segmentation-fault-when-using-tensorrt-to-compile-a-model/218872 "2022-06-27T02:07:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![814761970](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@814761970](https://forums.developer.nvidia.com/u/814761970)\
**Post date:** [June 27, 2022, 2:07am UTC](https://forums.developer.nvidia.com/t/segmentation-fault-when-using-tensorrt-to-compile-a-model/218872/1 "2022-06-27T02:07:42Z")

</div>

## Description

Compiling the sub-model attached receives a segmentation fault.

## Environment

**TensorRT Version** : 8.4.1.5  
**NVIDIA GPU** : RTX 3080Ti  
**NVIDIA Driver Version** : 510  
**CUDA Version** : 11.6  
**CUDNN Version** : 8.4.1  
**Operating System** : Ubuntu 20.04  
**Python Version (if applicable)** : 3.8

## Relevant Files

[model.onnx](https://forums.developer.nvidia.com/uploads/short-url/xvEpd0ovPjvbRM7OTM0OJJaxJy2.onnx) (942 Bytes)

## Steps To Reproduce

```python
import onnx
import tensorrt as trt

onnx_model = onnx.load("model.onnx")
model = onnx.checker.check_model(onnx_model, full_check=True)

builder = trt.Builder(trt.Logger(trt.Logger.WARNING))
network = builder.create_network(1 << (int)(
    trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH))
config = builder.create_builder_config()
config.set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, 1 * 1 << 30)
parser = trt.OnnxParser(network, trt.Logger(trt.Logger.WARNING))
assert parser.parse(onnx._serialize(onnx_model))
engine = builder.build_engine(network, config)
# ...

```

---

<div class="post-metadata">

**Author:** ![NVES](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nves/32/14043_2.png) [@NVES](https://forums.developer.nvidia.com/u/NVES)\
**Post date:** [June 27, 2022, 7:24pm UTC](https://forums.developer.nvidia.com/t/segmentation-fault-when-using-tensorrt-to-compile-a-model/218872/2 "2022-06-27T19:24:09Z")

</div>

Hi,  
Request you to share the ONNX model and the script if not shared already so that we can assist you better.  
Alongside you can try few things:

> **[Quick Start Guide — NVIDIA TensorRT](https://docs.nvidia.com/deeplearning/tensorrt/latest/getting-started/quick-start-guide.html)**

1. validating your model with the below snippet

# check\_model.py

import sys  
import onnx  
filename = yourONNXmodel  
model = onnx.load(filename)  
onnx.checker.check\_model(model).  
2) Try running your model with trtexec command.

> **[TensorRT/samples/trtexec at master · NVIDIA/TensorRT](https://github.com/NVIDIA/TensorRT/tree/master/samples/trtexec)**
>
> NVIDIA® TensorRT™ is an SDK for high-performance deep learning inference on NVIDIA GPUs. This repository contains the open source components of TensorRT. - NVIDIA/TensorRT

In case you are still facing issue, request you to share the trtexec “”–verbose"" log for further debugging  
Thanks!
