microsoft / archai

Accelerate your Neural Architecture Search (NAS) through fast, reproducible and modular research.
https://microsoft.github.io/archai
MIT License
467 stars 92 forks source link

[BUG] onnx_model.py is generating onnxruntime.capi.onnxruntime_pybind11_state.Fail #206

Closed lovettchris closed 1 year ago

lovettchris commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce

from archai.discrete_search.evaluators.onnx_model import AvgOnnxLatency
from archai.discrete_search.search_spaces.config import ArchConfig
from search_space.hgnet import StackedHourglass
from archai.discrete_search.api import ArchaiModel

arch_config = ArchConfig.from_file('config.json')
model = StackedHourglass(arch_config, num_classes=18)
archid = "123"
am = ArchaiModel(model, archid)
input_shape = (1, 3, 256, 256)

lat = AvgOnnxLatency(input_shape=input_shape, export_kwargs={'opset_version': 11})
lat.evaluate(am)

Expected behavior Should just work.

Screenshots

image

Desktop (please complete the following information):

Additional context

Removing the tmpfile and writing to a file named "model.onnx" and then loading that in the ONNX inference session works fine. So there is some weird interplay between with tempfile.NamedTemporaryFile(delete=False) as tmp_file: and the ONNX inference session. Perhaps we could just write the onnx model to the given --output folder somewhere near the checkpoints?

I posted a minimal repro here, we'll see what they say: https://github.com/microsoft/onnxruntime/issues/15295

pranavsharma commented 1 year ago

See resolution https://github.com/microsoft/onnxruntime/issues/15295#issuecomment-1491270786