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

BeartypeDecorHintPep484Exception with Torch ONNX's "typing.NoReturn" Type Hint #174

Closed
Crimsonfart opened this issue Sep 16, 2023 · 3 comments

Comments

@Crimsonfart
Copy link

Crimsonfart commented Sep 16, 2023

### It works now after i did this:

pip uninstall Beartype
pip install beartype==0.15.0

Hello:) The following problem occurred during installation:

Environment

Beartype version: Beartype 0.16.0
Torch version: torch 2.0.0
Python version: Python 3.10.13
Operating System: Win11

Issue Description

I encountered an issue when using Beartype alongside Torch, particularly when Torch is performing some ONNX-related operations. The error message is related to the typing.NoReturn type hint used in Torch's ONNX module.

The error traceback I received is as follows:

Traceback (most recent call last):
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\tts-generation-webui\server.py", line 40, in <module>
    from src.tortoise.generation_tab_tortoise import generation_tab_tortoise
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\tts-generation-webui\src\tortoise\generation_tab_tortoise.py", line 7, in <module>
    from src.tortoise.gen_tortoise import (
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\tts-generation-webui\src\tortoise\gen_tortoise.py", line 7, in <module>
    from tortoise.api import TextToSpeech, MODELS_DIR
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\tortoise\api.py", line 7, in <module>
    import torch
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\torch\__init__.py", line 1239, in <module>
    from torch import onnx as onnx
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\torch\onnx\__init__.py", line 12, in <module>
    from . import (  # usort:skip. Keep the order instead of sorting lexicographically
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\torch\onnx\symbolic_caffe2.py", line 4, in <module>
    from torch.onnx import symbolic_helper, symbolic_opset9 as opset9
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\torch\onnx\symbolic_helper.py", line 611, in <module>
    def _onnx_unsupported(op_name: str, value: Optional[_C.Value] = None) -> NoReturn:
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\decorcache.py", line 77, in beartype
    return beartype_object(obj, conf)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\decorcore.py", line 98, in beartype_object
    _beartype_object_fatal(obj, conf=conf, **kwargs)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\decorcore.py", line 147, in _beartype_object_fatal
    beartype_nontype(obj, **kwargs)  # type: ignore[return-value]
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\_decormore.py", line 178, in beartype_nontype
    return beartype_func(obj, **kwargs)  # type: ignore[return-value]
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\_decormore.py", line 242, in beartype_func
    func_wrapper_code = generate_code(bear_call)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\wrap\wrapmain.py", line 187, in generate_code
    code_check_return = _code_check_return(bear_call)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\wrap\wrapmain.py", line 669, in _code_check_return
    reraise_exception_placeholder(
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\error\utilerror.py", line 214, in reraise_exception_placeholder
    raise exception.with_traceback(exception.__traceback__)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\wrap\wrapmain.py", line 618, in _code_check_return
    ) = make_func_wrapper_code(hint_sane, bear_call.conf, cls_stack)  # type: ignore[assignment]
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\cache\utilcachecall.py", line 259, in _callable_cached
    raise exception
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\cache\utilcachecall.py", line 251, in _callable_cached
    return_value = args_flat_to_return_value[args_flat] = func(
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_decor\wrap\_wrapcode.py", line 86, in make_func_wrapper_code
    ) = make_check_expr(hint, conf, cls_stack)
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\cache\utilcachecall.py", line 259, in _callable_cached
    raise exception
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\cache\utilcachecall.py", line 251, in _callable_cached
    return_value = args_flat_to_return_value[args_flat] = func(
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_check\code\codemake.py", line 706, in make_check_expr
    die_if_hint_pep_unsupported(
  File "D:\AI\tts\one-click-installers-tts-6.0\one-click-installers-tts-6.0\installer_files\env\lib\site-packages\beartype\_util\hint\pep\utilpeptest.py", line 205, in die_if_hint_pep_unsupported
    raise BeartypeDecorHintPep484Exception(
beartype.roar.BeartypeDecorHintPep484Exception: Function torch.onnx.symbolic_helper._onnx_unsupported() return PEP 484 type hint "typing.NoReturn" invalid in this type hint context (i.e., "typing.NoReturn" valid only as non-nested return annotation).

Done!
Drücken Sie eine beliebige Taste . . .

Can you possibly help me with this? Thank you in advance!

@AndreasNieder
Copy link

changing the NoReturn to None in "installer_files\env\Lib\site-packages\torch\onnx\symbolic_helper.py"
makes it possible to start it again but i didn't check which implications this has.
image

@lustfeind
Copy link

Thank you Andreas! The UI starts now, but more things seem broken. Unfortunately I don't have the knowledge to debug this.

(tts) otto@MacBook-Pro-von-otto ~/Documents/tts-generation-webui % ./start_macos.sh
Loading extensions:
Loaded extension: callback_save_generation_ffmpeg
Loaded extension: empty_extension
Loaded extension: callback_save_generation_musicgen_ffmpeg
Loaded 2 callback_save_generation extensions.
Loaded 1 callback_save_generation_musicgen extensions.
2023-09-17 01:06:53 | INFO | fairseq.tasks.text_to_speech | Please install tensorboardX: pip install tensorboardX
Failed to load musicgen demo
No module named 'audiocraft'
Failed to load rvc demo
No module named 'rvc_beta'
Failed to load demucs demo
No module named 'demucs'
Starting Gradio server...
Gradio interface options:
inline: False
inbrowser: True
share: False
debug: False
enable_queue: True
max_threads: 40
auth: None
auth_message: None
prevent_thread_lock: False
show_error: False
server_name: 0.0.0.0
server_port: None
show_tips: False
height: 500
width: 100%
favicon_path: None
ssl_keyfile: None
ssl_certfile: None
ssl_keyfile_password: None
ssl_verify: True
quiet: True
show_api: True
file_directories: None
_frontend: True
Running on local URL: http://0.0.0.0:7860
2023-09-17 01:08:33 | ERROR | asyncio | Task exception was never retrieved
future: <Task finished name='jyjgqn18yet_157' coro=<Queue.process_events() done, defined at /Users/otto/Documents/tts-generation-webui/installer_files/env/lib/python3.10/site-packages/gradio/queueing.py:342> exception=1 validation error for PredictBody
event_id
Field required [type=missing, input_value={'data': ['standard'], 'e...on_hash': 'jyjgqn18yet'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.3/v/missing>
Traceback (most recent call last):
File "/Users/otto/Documents/tts-generation-webui/installer_files/env/lib/python3.10/site-packages/gradio/queueing.py", line 346, in process_events
client_awake = await self.gather_event_data(event)
File "/Users/otto/Documents/tts-generation-webui/installer_files/env/lib/python3.10/site-packages/gradio/queueing.py", line 219, in gather_event_data
data, client_awake = await self.get_message(event, timeout=receive_timeout)
File "/Users/otto/Documents/tts-generation-webui/installer_files/env/lib/python3.10/site-packages/gradio/queueing.py", line 448, in get_message
return PredictBody(**data), True
File "/Users/otto/Documents/tts-generation-webui/installer_files/env/lib/python3.10/site-packages/pydantic/main.py", line 165, in init
pydantic_self.pydantic_validator.validate_python(data, self_instance=pydantic_self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for PredictBody
event_id
Field required [type=missing, input_value={'data': ['standard'], 'e...on_hash': 'jyjgqn18yet'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.3/v/missing

@Ethorbit
Copy link

@Crimsonfart This issue should stay open until the fix is actually implemented in the repo since people will still run into it.

I appended the fix to the Dockerfile pip instructions and now the container runs correctly after rebuilding the image:

RUN pip3 uninstall --yes Beartype
RUN pip3 install beartype==0.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants