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

RuntimeError: Encountering a dict at the output of the tracer #16

Open
wolfbeast opened this issue Nov 23, 2023 · 1 comment
Open

RuntimeError: Encountering a dict at the output of the tracer #16

wolfbeast opened this issue Nov 23, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@wolfbeast
Copy link

wolfbeast commented Nov 23, 2023

Describe the bug

Following the instructions to install onnx on Windows, I'm running into a python runtime error when running save_onnx.py
The script successfully fetches a bunch of models, then errors out with a runtime error (see log).
I initially ran into issue #14 but following the diffusers update hint in the last post there I got past that, however ran into this issue with no hint how to solve that.

Reproduction

  1. Follow the instructions linked above, use Python 3.11 and the Python 3.11 onnx package. proceed to the last step of "Generating a onnx-based stable-diffusion v1.4 model"
  2. Run pip install -U diffusers to work around getattr() attribute name must be a string #14
  3. Run python ./save_onnx.py

Logs

Traceback (most recent call last):
  File "E:\sdiff\diffusers\examples\inference\save_onnx.py", line 66, in <module>
    convert_to_onnx(pipe.unet, pipe.vae.post_quant_conv, pipe.vae.decoder, text_encoder, height=512, width=512)
  File "E:\sdiff\diffusers\examples\inference\save_onnx.py", line 41, in convert_to_onnx
    traced_model = torch.jit.trace(unet, check_inputs[0], check_inputs=[check_inputs[1]], strict=True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Moonchild\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\jit\_trace.py", line 798, in trace
    return trace_module(
           ^^^^^^^^^^^^^
  File "C:\Users\Moonchild\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\jit\_trace.py", line 1065, in trace_module
    module._c._create_method_from_trace(
RuntimeError: Encountering a dict at the output of the tracer might cause the trace to be incorrect, this is only valid if the container structure does not change based on the module's inputs. Consider using a constant container instead (e.g. for `list`, use a `tuple` instead. for `dict`, use a `NamedTuple` instead). If you absolutely need this and know the side effects, pass strict=False to trace() to allow this behavior.

System Info

Python 3.11
updated diffusers to 0.23.1 after running into #14
@wolfbeast wolfbeast added the bug Something isn't working label Nov 23, 2023
@wolfbeast
Copy link
Author

Nuked the python env, installed 3.10; same error is thrown.
older python installers have been yanked and aren't available so I'm at a dead end here. Any help appreciated solving this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant