Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONNX export error when exporting Vision Transformer model from PyTorch to ONNX format #116306

Open
saifvazir opened this issue Dec 21, 2023 · 7 comments
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@saifvazir
Copy link

saifvazir commented Dec 21, 2023

🐛 Describe the bug

Hello, I've been trying to export the dinov2 vision transformer model to onnx format and have been getting an error:

torch.onnx.errors.UnsupportedOperatorError: Exporting the operator 'aten::_upsample_bicubic2d_aa' to ONNX opset version 15 is not supported.

I've tried with different versions of pytorch (previously with 2.0.0 and currently with the nightly build 2.3.0) and getting the same issue. I've inspected onnxscript and see that the aten_bicubic_2d function seems to be present (link here).

Thanks for your help :)

Steps to reproduce issue:

  1. Run this script:
import torch
import onnx
import onnxscript

dinov2_vits14_reg = torch.hub.load('facebookresearch/dinov2', 'dinov2_vits14_reg')

dummy_input = torch.randn(1,3,224,224)

torch.onnx.export(dinov2_vits14_reg, dummy_input, export_params=True, "model.onnx")

Versions

PyTorch version: 2.3.0.dev20231221+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.3
Libc version: glibc-2.31

Python version: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:26:04) [GCC 10.4.0] (64-bit runtime)
Python platform: Linux-4.14.327-246.539.amzn2.x86_64-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 470.57.02
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
Stepping: 7
CPU MHz: 3098.932
BogoMIPS: 5000.00
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 128 KiB
L1i cache: 128 KiB
L2 cache: 4 MiB
L3 cache: 35.8 MiB
NUMA node0 CPU(s): 0-7
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit: KVM: Vulnerable
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed: Vulnerable
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke avx512_vnni

Versions of relevant libraries:
[pip3] numpy==1.24.1
[pip3] onnx==1.15.0
[pip3] onnxscript==0.1.0.dev20231213
[pip3] pytorch-triton==2.2.0+e28a256d71
[pip3] torch==2.3.0.dev20231221+cu118
[pip3] torchaudio==2.2.0.dev20231221+cu118
[pip3] torchvision==0.18.0.dev20231221+cu118
[conda] blas 1.0 mkl conda-forge
[conda] mkl 2023.1.0 h84fe81f_48680 conda-forge
[conda] mkl-include 2023.1.0 h84fe81f_48680 conda-forge
[conda] numpy 1.23.5 py310h53a5b5f_0 conda-forge
[conda] pytorch-cuda 11.8 h7e8668a_3 https://aws-ml-conda-pre-prod-ec2.s3.us-west-2.amazonaws.com
[conda] pytorch-lightning 1.9.5 pypi_0 pypi
[conda] pytorch-mutex 1.0 cuda https://aws-ml-conda-pre-prod-ec2.s3.us-west-2.amazonaws.com
[conda] sagemaker-pytorch-training 2.8.0 pypi_0 pypi
[conda] torch 2.0.0 pypi_0 pypi
[conda] torchaudio 2.0.1 py310_cu118 https://aws-ml-conda-pre-prod-ec2.s3.us-west-2.amazonaws.com
[conda] torchdata 0.6.0 py310 https://aws-ml-conda-pre-prod-ec2.s3.us-west-2.amazonaws.com
[conda] torchmetrics 0.10.3 pypi_0 pypi
[conda] torchnet 0.0.4 pypi_0 pypi
[conda] torchtext 0.15.1 py310 https://aws-ml-conda-pre-prod-ec2.s3.us-west-2.amazonaws.com
[conda] torchvision 0.15.1 pypi_0 pypi
[conda] triton 2.0.0 pypi_0 pypi

Tasks

No tasks being tracked yet.
@jbschlosser jbschlosser added module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Dec 26, 2023
@github-project-automation github-project-automation bot moved this to Inbox in ONNX Dec 26, 2023
@justinchuby
Copy link
Collaborator

ONNX Script is used only by the new dynamo exporter (torch.onnx.dynamo_export). Consider using that to see if it succeeds. Be sure to use the latest PyTorch and ONNX versions: https://pytorch.org/docs/stable/onnx_dynamo.html

@justinchuby
Copy link
Collaborator

Also aten_upsample_bicubic2d is not implemented yet. It is WIP in microsoft/onnxscript#1208

@justinchuby
Copy link
Collaborator

Tested with dynamo. It is still _upsample_bicubic2d_aa that needs to be supported.

@justinchuby
Copy link
Collaborator

Tracked by microsoft/onnxscript#1159

@thiagocrepaldi
Copy link
Collaborator

Tracked by microsoft/onnxscript#1159

maybe @fatcat-z and @xiaowuhu can help implementing these

@Gasp34
Copy link

Gasp34 commented Jul 3, 2024

@saifvazir have you found a way to do it ?

@dgcnz
Copy link

dgcnz commented Sep 11, 2024

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
Status: Inbox
Development

No branches or pull requests

6 participants