ray-project / ray

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
32.95k stars 5.58k forks source link

[Bug] `import ray` fails on fresh install of macOS Monterey #20084

Closed 28140 closed 1 year ago

28140 commented 2 years ago

Search before asking

Ray Component

Ray Core

What happened + What you expected to happen

Hi there!

On a fresh install of macOS Monterey, I'm running the following commands:

python3 -m venv DRL source DRL/bin/activate /Users/user/DRL/bin/python3 -m pip install --upgrade pip pip install torch pip install 'ray[rllib]' python3

and this is what I'm getting:

>>> import ray Traceback (most recent call last): File "\<stdin>", line 1, in \<module> File "/Users/user/DRL/lib/python3.8/site-packages/ray/__init__.py", line 91, in import ray._raylet # noqa: E402 File "python/ray/_raylet.pyx", line 16, in init ray._raylet ImportError: dlopen(/Users/user/DRL/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_Py_GetArgcArgv' >>>

Does anybody have a clue about what's happening here?

Thank you!

Versions / Dependencies

Ray 1.8.0 Python 3.8.9 macOS Monterey PyTorch 1.10.0

Reproduction script

python3 -m venv DRL /Users/user/DRL/bin/python3 -m pip install --upgrade pip source DRL/bin/activate pip install torch pip install 'ray[rllib]'

python3 import ray

Anything else

The problem occurs every time.

Are you willing to submit a PR?

amogkam commented 2 years ago

Hey @28140, just to confirm this is also happening when you do just a standard pip install ray (and not pip install ray[rllib]), is that right?

Maybe try out some of the responses here https://stackoverflow.com/questions/60684146/airflow-initdb-undefined-symbol-py-getargcargv and see if any of those work for you. It might be related to something with your Python installation.

28140 commented 2 years ago

Hey @28140, just to confirm this is also happening when you do just a standard pip install ray (and not pip install ray[rllib]), is that right?

Yes, @amogkam, it is also happening when I do a standard \'pip install ray\' (and not `pip install \'ray[rllib]\'`).

Maybe try out some of the responses here https://stackoverflow.com/questions/60684146/airflow-initdb-undefined-symbol-py-getargcargv and see if any of those work for you. It might be related to something with your Python installation.

Thanks, I'll do that.

wrmichaelmak commented 2 years ago

Hey @28140, did you try out the solutions listed at stackoverflow? I tried them out but does not seem to be working. Was wondering if you got them working... I also tried to use a venv but no luck as well.

Innixma commented 2 years ago

Can confirm this bug also occurs on:

MacOS Big Sur Version 11.6 Python 3.8.9 ray==1.7.0 & ray==1.9.0

Mac Model:

MacBook Pro (16-inch, 2019)
Processor: 2.6 GHz 6-Core Intel Core i7
Memory: 16 GB 2667 MHz DDR4
Graphics: AMD Radeon Pro 5300M 4 GB + Intel UHD Graphics 630 1536 M
pip install -U ray
>>> import ray
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/neerick/workspace/virtual/autogluon/lib/python3.8/site-packages/ray/__init__.py", line 91, in <module>
    import ray._raylet  # noqa: E402
  File "python/ray/_raylet.pyx", line 16, in init ray._raylet
ImportError: dlopen(/Users/neerick/workspace/virtual/autogluon/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
  Referenced from: /Users/neerick/workspace/virtual/autogluon/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so
  Expected in: flat namespace
 in /Users/neerick/workspace/virtual/autogluon/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so

We are adding ray to the AutoGluon AutoML package, and this issue is currently a blocker for using ray by default on MacOS.

amogkam commented 2 years ago

Is the install being done on an M1 Mac? If so we have specific instructions for that here https://docs.ray.io/en/latest/installation.html#apple-silicon-support

Innixma commented 2 years ago

@amogkam No, this is on 2019 x86:

MacBook Pro (16-inch, 2019) Processor: 2.6 GHz 6-Core Intel Core i7 Memory: 16 GB 2667 MHz DDR4 Graphics: AMD Radeon Pro 5300M 4 GB + Intel UHD Graphics 630 1536 M

stale[bot] commented 2 years ago

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

You can always ask for help on our discussion forum or Ray's public slack channel.

benblamey commented 2 years ago

Can confirm the issue on macOS Monterey, (processor is 2.3 GHz Dual-Core Intel Core i5), Python 3.8.9

benblamey commented 2 years ago

Possibly because the symbol _Py_GetArgcArgv is not being exported for some versions of Python 3? See: https://github.com/python/cpython/issues/85087

benblamey commented 2 years ago

Related issues: https://github.com/ray-project/ray/issues/22408 https://github.com/ray-project/ray/issues/10428

edi-bice-by commented 2 years ago

Recreated venv using Python 3.10, after was forced to upgrade to Monterey, installing ray there got rid of this error which I was facing with Python 3.8 installed prior to the upgrade

mattip commented 1 year ago

Closing, please open a new issue if the problem re-appears.