mit-han-lab / torchsparse

[MICRO'23, MLSys'22] TorchSparse: Efficient Training and Inference Framework for Sparse Convolution on GPUs.
https://torchsparse.mit.edu
MIT License
1.15k stars 131 forks source link

[Installation] ImportError in version 1.4.0 on M1 #297

Closed eat-slim closed 2 months ago

eat-slim commented 3 months ago

Is there an existing issue for this?

Have you followed all the steps in the FAQ?

Current Behavior

Successfully installed torchsparse-1.4.0 but encountered ImportError on M1.

During installation, running the official command directly will encounter compilation errors because clang cannot handle the -fopenmp parameter. Therefore, I adjusted the command and compiled using g++:

export CXX=/opt/homebrew/bin/g++-13
export CPLUS_INCLUDE_PATH=CPLUS_INCLUDE_PATH:/opt/homebrew/Cellar/google-sparsehash/2.0.4/include
pip install --upgrade git+https://github.com/mit-han-lab/torchsparse.git@v1.4.0

Although the installation was successful, I noticed an issue in the log:

Collecting git+https://github.com/mit-han-lab/torchsparse.git@v1.4.0
  Cloning https://github.com/mit-han-lab/torchsparse.git (to revision v1.4.0) to /private/var/folders/0j/5x_5wry514q6wjctlvqm0cf00000gn/T/pip-req-build-cehloti9
  Running command git clone --filter=blob:none --quiet https://github.com/mit-han-lab/torchsparse.git /private/var/folders/0j/5x_5wry514q6wjctlvqm0cf00000gn/T/pip-req-build-cehloti9
  Running command git checkout -q 74099d10a51c71c14318bce63d6421f698b24f24
  Resolved https://github.com/mit-han-lab/torchsparse.git to commit 74099d10a51c71c14318bce63d6421f698b24f24
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: torchsparse
  Building wheel for torchsparse (setup.py) ... done
  Created wheel for torchsparse: filename=torchsparse-1.4.0-cp38-cp38-macosx_10_9_x86_64.whl size=111785 sha256=aa3ffa229dfac6897705e9438dc7cb0474b009470f0917fe8c3ce691146320e0
  Stored in directory: /private/var/folders/0j/5x_5wry514q6wjctlvqm0cf00000gn/T/pip-ephem-wheel-cache-02v_v1ke/wheels/a0/9a/4c/f32e92e50cd33d04a30f31cbb2d0a6defb36cb5f34937352e4
Successfully built torchsparse
Installing collected packages: torchsparse
Successfully installed torchsparse-1.4.0

Note that this wheel seems to be built for x86_64 instead of ARM
Created wheel for torchsparse: filename=torchsparse-1.4.0-cp38-cp38-macosx_10_9_x86_64.whl

when running import torchsparse.backend, ImportError was thrown.

Error Line

>>> import torchsparse.backend
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/dingziheng/opt/anaconda3/envs/PyTorch/lib/python3.8/site-packages/torchsparse/backend.cpython-38-darwin.so, 0x0002): tried: '/Users/dingziheng/opt/anaconda3/envs/PyTorch/lib/python3.8/site-packages/torchsparse/backend.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))

Environment

- GCC: 13.2.0
- PyTorch: 1.13.0

Full Error Log

Error Log Traceback (most recent call last): File "\", line 1, in \ ImportError: dlopen(/Users/dingziheng/opt/anaconda3/envs/PyTorch/lib/python3.8/site-packages/torchsparse/backend.cpython-38-darwin.so, 0x0002): tried: '/Users/dingziheng/opt/anaconda3/envs/PyTorch/lib/python3.8/site-packages/torchsparse/backend.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
zhijian-liu commented 2 months ago

@eat-slim, thank you for reporting this issue. Unfortunately, we haven't attempted to make TorchSparse compatible with M chips yet.