# Not able to export large model with onnx

**URL:** <https://discuss.pytorch.org/t/not-able-to-export-large-model-with-onnx/122506>\
**Category:** Uncategorized\
**Created:** [May 27, 2021, 2:38am UTC](https://discuss.pytorch.org/t/not-able-to-export-large-model-with-onnx/122506 "2021-05-27T02:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeepakSaini119](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/deepaksaini119/32/17267_2.png) [@DeepakSaini119](https://discuss.pytorch.org/u/DeepakSaini119)\
**Post date:** [May 27, 2021, 2:38am UTC](https://discuss.pytorch.org/t/not-able-to-export-large-model-with-onnx/122506/1 "2021-05-27T02:38:01Z")

</div>

I am trying to export a model(which when dumped on disk as a pt file, is 4GB). The code I use is:

```python
net.eval()
torch.onnx.export(net, # model being run
                  (doc_embeddings, shortlist), # model input (or a tuple for multiple inputs)
                  "/path/to/a/folder/net.onnx", # where to save the model (can be a file or file-like object)
                  opset_version=11, # the ONNX version to export the model to
                  input_names = ['doc_embeddings', 'shortlist'], # the model's input names
                  output_names = ['scores'], # the model's output names
                  dynamic_axes={'doc_embeddings' : {0 : 'batch_size'}, # variable length axes
                                'shortlist' : {0 : 'batch_size', 1: 'num_shortlist'},
                                'scores' : {0 : 'batch_size', 1: 'num_shortlist'}},
                  use_external_data_format=True,
                  verbose=True)

```

But this doesn’t work and I get the error: `RuntimeError: Exporting model exceed maximum protobuf size of 2GB. Please call torch.onnx.export with use_external_data_format=True.` I would ideally expect that the model would be exported with external files after specifying `use_external_data_format=True`

---

<div class="post-metadata">

**Author:** ![JulesBelveze](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/julesbelveze/32/44219_2.png) [@JulesBelveze](https://discuss.pytorch.org/u/JulesBelveze)\
**Post date:** [April 7, 2022, 1:20pm UTC](https://discuss.pytorch.org/t/not-able-to-export-large-model-with-onnx/122506/2 "2022-04-07T13:20:18Z")

</div>

+1 I’m having the same problem over here
