aws-neuron / aws-neuron-sdk

Powering AWS purpose-built machine learning chips. Blazing fast and cost effective, natively integrated into PyTorch and TensorFlow and integrated with your favorite AWS services
https://aws.amazon.com/machine-learning/neuron/
Other
444 stars 148 forks source link

``AttributeError: module 'mpmath' has no attribute 'rational'`` after installing torch-neuronx 2.1beta #841

Closed jeffhataws closed 2 months ago

jeffhataws commented 7 months ago

For torch-neuronx 2.1beta from Neuron SDK Release 2.16, if you are installing with --pre pip installation flag as instructed in the installation guide, it will bring in mpmath==1.4.0a0 (alpha version prereleased 2/22/24) via sympy which is a dependency of torch, and you will see the following error :

aws_neuron_venv/lib/python3.8/site-packages/sympy/core/numbers.py:4567: in <module>
    _sympy_converter[type(mpmath.rational.mpq(1, 2))] = sympify_mpmath_mpq
E   AttributeError: module 'mpmath' has no attribute 'rational'

To workaround the issue, for torch-neuronx 2.1beta, please add a pin mpmath==1.3, i.e.:

python -m pip install --upgrade neuronx-cc==2.* --pre torch-neuronx==2.1.* torchvision mpmath==1.3

See also https://github.com/sympy/sympy/issues/26273 .

jeffhataws commented 2 months ago

torch-neuronx 2.1 was no longer beta during SDK 2.18 release, and sympy has already fixed the dependency in https://github.com/pytorch/rl/pull/1988.