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

"AttributeError: module 'mpmath' has no attribute 'rational'" when recreating .venv (+workaround) #2095

Open
one-lithe-rune opened this issue Feb 23, 2024 · 2 comments

Comments

@one-lithe-rune
Copy link
Contributor

Found this when trying to setup the .venv on Linux. But this happens for me on both SHARK-1.0 and sd-studio2 branches, on both Windows and Linux.

The workaround is to do pip install mpmath==1.3.0. But I'm guessing its an upstream requirements problem rather than a SHARK requirements one?

(shark1.venv) PS C:\develop\SHARK> shark-run
72175701 (HEAD -> SHARK-1.0, tag: 20240126.1139, upstream/SHARK-1.0, origin/SHARK-1.0) SDXL tweaks (#2072)
On branch SHARK-1.0
Your branch is up to date with 'upstream/SHARK-1.0'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        apps/shark_studio/web/models/

nothing added to commit but untracked files present (use "git add" to track)
Traceback (most recent call last):
  File "C:\develop\SHARK\apps\stable_diffusion\web\index.py", line 5, in <module>
    import apps.stable_diffusion.web.utils.app as app
  File "C:\develop\SHARK\apps\stable_diffusion\web\utils\app.py", line 10, in <module>
    from apps.stable_diffusion.src import args
  File "C:\develop\SHARK\apps\stable_diffusion\src\__init__.py", line 1, in <module>
    from apps.stable_diffusion.src.utils import (
  File "C:\develop\SHARK\apps\stable_diffusion\src\utils\__init__.py", line 12, in <module>
    from apps.stable_diffusion.src.utils.sd_annotation import sd_model_annotation
  File "C:\develop\SHARK\apps\stable_diffusion\src\utils\sd_annotation.py", line 3, in <module>
    from shark.model_annotation import model_annotation, create_context
  File "C:\develop\SHARK\shark\__init__.py", line 4, in <module>
    from torch._dynamo import register_backend
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\torch\_dynamo\__init__.py", line 2, in <module>
    from . import allowed_functions, convert_frame, eval_frame, resume_execution
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\torch\_dynamo\allowed_functions.py", line 30, in <module>
    from .utils import hashable, is_safe_constant, NP_SUPPORTED_MODULES
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\torch\_dynamo\utils.py", line 89, in <module>
    import torch.fx.experimental.symbolic_shapes
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\torch\fx\experimental\symbolic_shapes.py", line 38, in <module>
    from torch.utils._sympy.functions import FloorDiv, Mod, IsNonOverlappingAndDenseIndicator
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\torch\utils\_sympy\functions.py", line 1, in <module>
    import sympy
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\sympy\__init__.py", line 30, in <module>
    from sympy.core.cache import lazy_function
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\sympy\core\__init__.py", line 9, in <module>
    from .expr import Expr, AtomicExpr, UnevaluatedExpr
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\sympy\core\expr.py", line 4159, in <module>
    from .mul import Mul
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\sympy\core\mul.py", line 2193, in <module>
    from .numbers import Rational
  File "C:\develop\SHARK\shark1.venv\Lib\site-packages\sympy\core\numbers.py", line 4567, in <module>
    _sympy_converter[type(mpmath.rational.mpq(1, 2))] = sympify_mpmath_mpq
                          ^^^^^^^^^^^^^^^
AttributeError: module 'mpmath' has no attribute 'rational'

Looks like its picking up an alpha version of that dependency somehow:

(shark1.venv) PS C:\develop\SHARK>pip show mpmath
Name: mpmath
Version: 1.4.0a0
Summary: Python library for arbitrary-precision floating-point arithmetic
Home-page:
Author:
Author-email: Fredrik Johansson <fredrik.johansson@gmail.com>
License: BSD
Location: C:\develop\SHARK\shark1.venv\Lib\site-packages
Requires:
Required-by: sympy
@summer996
Copy link

summer996 commented Feb 26, 2024

sudo pip install mpmath==1.3.0

q10 added a commit to q10/FBGEMM that referenced this issue Feb 26, 2024
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095
q10 added a commit to q10/FBGEMM that referenced this issue Feb 26, 2024
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095
q10 added a commit to q10/FBGEMM that referenced this issue Feb 26, 2024
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095
q10 added a commit to q10/FBGEMM that referenced this issue Feb 26, 2024
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095
q10 added a commit to q10/FBGEMM that referenced this issue Feb 26, 2024
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095
facebook-github-bot pushed a commit to pytorch/FBGEMM that referenced this issue Feb 26, 2024
Summary:
- Fix mpmath dependency to allow tests to pass again; see

jianyicheng/mase-docker#9
nod-ai/SHARK#2095

Pull Request resolved: #2356

Reviewed By: spcyppt

Differential Revision: D54212358

Pulled By: q10

fbshipit-source-id: dfdf842069462a34514f78aee00cdb4a300392ce
@one-lithe-rune
Copy link
Contributor Author

PR for add the workaround to the Shark-1.0 requirements: #2099
I believe Studio2 should be fixed by the merged nod-ai/SHARK-Turbine#477

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