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

Fixes broken install of dev-requirements on apple silicon (Apple M1 Macbook Pro) #326

Merged
merged 5 commits into from
Mar 23, 2022

Conversation

andyk
Copy link
Contributor

@andyk andyk commented Mar 19, 2022

Up until now, on my Macbook Pro M1 I've been ignoring the rllib tests which have failed with a segfault.

However I recently:

  1. switched to the arm64 version of brew (I previously had installed the x86 vesion which I guess was using rosetta for much of what it was installing?)
  2. used that new brew to re-install conda
  3. made a new env
  4. installed scipy via conda (since installing scipy via pip tries compiling numpy on apple silicon which fails)
  5. tried pip installing sb3 requirements, and this fails because apparently torch 1.9.1 is not available on MacOS w/ apple silicon, but 1.9.0 is.

so this changes the version of torch in the example_agent requirements.txt file to 1.9.0, which fixes the error on my Macbook Pro (MBP) M1.

Also, this PR updates the string we look for in sys.platform from "windows" to "win32". I looked at the test output on the github workflow windows machine and it was showing:

Ignoring torch: markers 'sys_platform == "linux"' don't match your environment
Ignoring torch: markers 'sys_platform == "darwin"' don't match your environment
Ignoring torch: markers 'sys_platform == "windows"' don't match your environment

Which seemed odd since I would expect it to be matching "windows", so I looked it up and per https://docs.python.org/3/library/sys.html?highlight=sys#sys.platform "win32" is the correct string, not "windows".

So this PR also fixes our use of that string in two example_agent requirements.txt files.

…stalled conda, made a new env, installed scipy via conda (since installing scipy via pip tries compiling numpy on apple silicon which fails), and then try pip installing sb3 requirements, and that fails because apparently torch 1.9.1 is not available on MacOS w/ apple silicon?, but 1.9.0 is!
@andyk
Copy link
Contributor Author

andyk commented Mar 19, 2022

Also, interestingly, after installing scipy via conda, and then running python install_requirements.py on my M1 (and having it work in this branch), I get the following error when I try to import ray in my python shell:

>>> import ray
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/ray/__init__.py", line 36, in _configure_system
    import grpc  # noqa: F401
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/grpc/_compression.py", line 15, in <module>
    from grpc._cython import cygrpc
ImportError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 2): Symbol not found: _CFRelease
  Referenced from: /opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so
  Expected in: flat namespace
 in /opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/ray/__init__.py", line 83, in <module>
    _configure_system()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/ray/__init__.py", line 38, in _configure_system
    raise ImportError(
ImportError: Failed to import grpc on Apple Silicon. On Apple Silicon machines, try `pip uninstall grpcio; conda install grpcio`. Check out https://docs.ray.io/en/master/installation.html#apple-silicon-support for more details.

Then, if i follow these instructions, i.e. after I run pip uninstall grpcio; conda install grpcio at the shell, then import ray works.

@andyk andyk changed the title Fixes broken install of dev-requirements on apple silicon Fixes broken install of dev-requirements on apple silicon (Apple M1 Macbook Pro) Mar 19, 2022
@andyk andyk marked this pull request as ready for review March 22, 2022 18:31
@andyk andyk requested a review from nickjalbert March 22, 2022 18:31
@andyk andyk self-assigned this Mar 22, 2022
Copy link
Contributor

@nickjalbert nickjalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing those string.

As discussed, before merge maybe we unify the sb3 torch requirements to also use 1.10.2 because that seems to work and has an M1 wheel?

pip uninstall grpcio; conda install grpci

Also, how hard would it be to make install_requirements.py script automatically do this uninstall/reinstall on M1s? Or does that assume too much about the environment (e.g. conda existing).

@andyk
Copy link
Contributor Author

andyk commented Mar 23, 2022

I changed updated the sb3 torch requirement to 1.10.2 and updated install_requirements.txt to handle the case of apple-silicon.

I also noticed a conflict with the gym requirements between sb3 (which wants <0.20) and rllib_agent (which wants 0.21.0) so I changed rllib_agent to use 0.19.0 and tested that it didn't break anything on my Macbook.

@andyk andyk merged commit 6c179f8 into agentos-project:master Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants