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

Issues installing pytorch-sparse on macOS (with METIS) #345

Open
islijepcevic opened this issue Oct 20, 2023 · 1 comment
Open

Issues installing pytorch-sparse on macOS (with METIS) #345

islijepcevic opened this issue Oct 20, 2023 · 1 comment

Comments

@islijepcevic
Copy link

Hello,
I'm having some issues correctly installing pytorch sparse with METIS support on a Mac with apple silicon. I'm trying to install for pytorch 2.1.0, without any CUDA support.

Initially, I installed as follows:

CUDA=cpu
pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.1.0+${CUDA}.html

However, I was running into following issues when eventually trying to import

$ python
>>> from torch_sparse import SparseTensor, set_diag
...
...
OSError: dlopen(~/miniconda3/envs/gnnc/lib/python3.11/site-packages/torch_sparse/_metis_cpu.so, 0x0006): symbol not found in flat namespace '_METIS_PartGraphKway'

I continued by installing METIS as suggested in the docs. Here is the history of commands I used:

# Remove existing installations, and clear cache so pip doesn't reuse downloaded ones.
pip uninstall torch-scatter torch-sparse
pip cache remove torch-scatter
pip cache remove torhc-sparse
# METIS
gunzip metis-5.1.0.tar.gz
tar -xvf metis-5.1.0.tar
cd metis-5.1.0/
# ... make sure IDXTYPEWIDTH=64 in `include/metis.h`
make config shared=1 prefix=~/.local
make install
export WITH_METIS=1
export CPLUS_INCLUDE_PATH=~/.local/include
export LIBRARY_PATH=~/.local/lib
export LD_LIBRARY_PATH=~/.local/lib
pip install torch-scatter torch-sparse

However, a similar error still appears.

$ python
>>> from torch_sparse import SparseTensor, set_diag
...
...
OSError: dlopen(~/miniconda3/envs/gnn-pip/lib/python3.11/site-packages/torch_sparse/_version_cpu.so, 0x0006): Library not loaded: libmetis.dylib
  Referenced from: <BA2B5C47-7378-35F1-B4B8-A6F3CFFCBCFC> ~/miniconda3/envs/gnn-pip/lib/python3.11/site-packages/torch_sparse/_version_cpu.so
  Reason: tried: 'libmetis.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibmetis.dylib' (no such file), 'libmetis.dylib' (no such file), '~/scratch-code/metis-5.1.0/libmetis.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/<path-to-metis-download>/metis-5.1.0/libmetis.dylib' (no such file), '<path-to-metis-download>/metis-5.1.0/libmetis.dylib' (no such file)

If needed, here is the GCC version I currently have:

$ gcc --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0

Ideally, things would work without manually building METIS, but I understand this may be difficult to support for apple silicon. I tried also to build without shared=1, but similar errors happened. I'm happy to try different versions of python or pytorch, if that is potentially the issue, and also I can share any additional details if needed.

Thank you for help looking into this!

@TheodorosBouloumis
Copy link

TheodorosBouloumis commented Apr 3, 2024

Hi, I have the same issue. Did you manage to find a solution?
Thanks!
EDIT: In case someone, checks here, the only thing that worked for me (Apple M3 pro macbook pro) was to install the torch version 2.0.0. (it didn't work with 2.2 nor 2.1)

  1. Make sure you pip3 uninstall "all torch related packages"
  2. pip3 install torch==2.0.0
  3. pip3 install torch-geometric #that was (v.2.5.2)
  4. pip3 install torch_scatter torch_sparse -f https://data.pyg.org/whl/torch-2.0.0+cpu.html #these were 2.1.2 and 0.6.18 versions, respectively.

Things work fine now!

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