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

Torch/Architecture clashes for Mac users #209

Open
ThibaultLSDC opened this issue Jan 27, 2025 · 5 comments
Open

Torch/Architecture clashes for Mac users #209

ThibaultLSDC opened this issue Jan 27, 2025 · 5 comments

Comments

@ThibaultLSDC
Copy link
Collaborator

ThibaultLSDC commented Jan 27, 2025

changed the issue

@gabrielhuang
Copy link

More details:

>>> import torch

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.3 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/__init__.py", line 1477, in <module>
    from .functional import *  # noqa: F403
  File "/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/functional.py", line 9, in <module>
    import torch.nn.functional as F
  File "/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/Users/gabriel.huang/miniconda3/envs/raa/lib/python3.12/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),

seems like a torch issue

@gabrielhuang
Copy link

Seems related to this thread

TLDR; mac x86 binaries for pytorch are deprecated after 2.2.2. could have to do with our conda distribution. i have a M2 laptop but maybe not my python distro

@gabrielhuang
Copy link

$ python -c "import platform; print(platform.processor())"
i386

That should be arm64 or something. I will fix my python fdistribution and update

@gabrielhuang
Copy link

Running arch in ITerm2 app shows i386 but running it in the default Terminal app shows arm64. I assume the installed python just follows whatever architecture is returned by arch.

In image below Terminal thinks architecture is arm64 but since i installed mamba from Iterm2 architecture is wrong
Image

@gabrielhuang
Copy link

gabrielhuang commented Jan 29, 2025

Setting up environment on Mac M1, M2 chips

  1. Ensure terminal is running under correct architecture.
$ arch # must return `arm64`

If wrong arch and using Iterm2, configure Profiles->General->Command->arch -arm64 /bin/zsh

  1. Download mamba. If using homebrew, ensure brew is the arm64 version with brew config. If not, you need to reinstall homebrew for arm64. If needed follow this instruction to install without root. Once brew is working, do this
$ brew install micromamba
  1. Create python environment
mamba create -n raa -c conda-forge python=3.12
python -c "import platform; print(platform.processor())"  # verify platform is correct 

@ThibaultLSDC ThibaultLSDC changed the title Solve dependencies for 3.13 Torch/Architecture clashes for Mac users Feb 4, 2025
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

2 participants