som-shahlab/femr

Documentation for installing xformers on macOS

scottfleming opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
If you try to install xformers with pip locally on macOS, you may encounter something like the following error:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/user/opt/anaconda3/envs/myenv/include -fPIC -O2 -isystem /Users/user/opt/anaconda3/envs/myenv/include -I/private/var/folders/2z/c7gdn271141d2knctlpwht8m0000gq/T/pip-install-2foa_03p/xformers_32982396ee994be9ae77099087c9b6fc/xformers/csrc -I/Users/user/opt/anaconda3/envs/myenv/lib/python3.10/site-packages/torch/include -I/Users/user/opt/anaconda3/envs/myenv/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/Users/user/opt/anaconda3/envs/myenv/lib/python3.10/site-packages/torch/include/TH -I/Users/user/opt/anaconda3/envs/myenv/lib/python3.10/site-packages/torch/include/THC -I/Users/user/opt/anaconda3/envs/myenv/include/python3.10 -c xformers/csrc/attention/attention.cpp -o build/temp.macosx-10.9-x86_64-cpython-310/xformers/csrc/attention/attention.o -O3 -std=c++17 -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_clang\" -DPYBIND11_STDLIB=\"_libcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1002\" -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0
      clang: error: unsupported option '-fopenmp'
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for xformers
  Running setup.py clean for xformers
Failed to build xformers
ERROR: Could not build wheels for xformers, which is required to install pyproject.toml-based projects

Following this stack overflow post, installing llvm via brew can solve the issue:

brew install llvm libomp
export CC=/usr/local/opt/llvm/bin/clang

Describe the solution you'd like
This may not actually need formal documentation, but I thought it would be good to have in the repo's issues so that if someone runs into a similar issue they can find the answer here.

I think this is actually good to add to the README. xformers is a niche library and I wouldn't expect our users to know about the its limitations.

I just added it as a comment in the README now.

Thanks for pointing this out (especially because I don't use MacOS!)