# Segmentation fault (core dumped): It crashes when compiling a ONNX model on GPU using the latest version of TVM

**URL:** <https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775>\
**Category:** Troubleshooting\
**Created:** [May 16, 2022, 6:36am UTC](https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775 "2022-05-16T06:36:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evans](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/evans/32/4740_2.png) [@Evans](https://discuss.tvm.apache.org/u/Evans)\
**Post date:** [May 16, 2022, 6:36am UTC](https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775/1 "2022-05-16T06:36:05Z")

</div>

TVM throws `Segmentation fault (core dumped)` at `relay.build()` when compile a ONNX model in CUDA.

Please notice that:

1. the script run well when replace ‘cuda’ with ‘llvm’
2. the script run well using tvm0.8 version (commit-id: ef6e52f191888ee2a5f2221bde3b69391766903f)
3. the script run well using `relay.create_executor()`

I am curious about this crash, wich your comments, Thanks!

## The reproducible script

```auto
import tvm
import tvm.relay as relay
import onnx

model_path = 'lenet5-fashion-mnist_origin.onnx'
batch_size = 1
target = 'cuda'
predict_model = onnx.load(model_path)

input_shape = (batch_size, 28, 28, 1)

shape_dict = {'conv2d_1_input': input_shape}
print("shape_dict", shape_dict)

irmod, params = relay.frontend.from_onnx(predict_model, shape_dict, freeze_params=True)
# irmod = relay.transform.DynamicToStatic()(irmod)
print('TVM/Relay import model successfully!')

# -----------------------Compile the RelayIR--------------------------
graph, lib, params = relay.build_module.build(irmod, target=target, params=params)

```

The model is available by this link

> **[lenet5-fashion-mnist\_origin.onnx](https://drive.google.com/file/d/1OHkk6yvRrMi2KPR2XX62P3T3nqiv5Ez4/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![Evans](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/evans/32/4740_2.png) [@Evans](https://discuss.tvm.apache.org/u/Evans)\
**Post date:** [May 20, 2022, 2:07pm UTC](https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775/2 "2022-05-20T14:07:37Z")

</div>

I update TVM to the newest version (2022-5-20), This script also crash when using relay.create\_executor().

@FrozenGene @comaniac , could you help me check this crash? Thanks!

---

<div class="post-metadata">

**Author:** ![masahi](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/masahi/32/74_2.png) [@masahi](https://discuss.tvm.apache.org/u/masahi)\
**Post date:** [May 20, 2022, 7:49pm UTC](https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775/3 "2022-05-20T19:49:19Z")

</div>

It doesn’t reproduce on my environment.

Can you try `gdb --args python your_script.py` and show the backtrace?

---

<div class="post-metadata">

**Author:** ![Evans](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/evans/32/4740_2.png) [@Evans](https://discuss.tvm.apache.org/u/Evans)\
**Post date:** [May 24, 2022, 6:52am UTC](https://discuss.tvm.apache.org/t/segmentation-fault-core-dumped-it-crashes-when-compiling-a-onnx-model-on-gpu-using-the-latest-version-of-tvm/12775/4 "2022-05-24T06:52:33Z")

</div>

@masahi Thanks for your reply!

The backtrace is follows:

```auto
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
malloc_consolidate (av=av@entry=0x7ffff7409c40 <main_arena>) at malloc.c:4469
4469	malloc.c: No such file or directory

```
