Skip to content

Commit a9a3345

Browse files
committed
fix installation bug with openmp on mac
1 parent 4ce3b59 commit a9a3345

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ cd fasttreeshap
5050
pip install .
5151
```
5252

53+
Installation troubleshooting:
54+
* On Macbook, if an error message `ld: library not found for -lomp` pops up, run the following command line before installation ([Reference](https://iscinumpy.gitlab.io/post/omp-on-high-sierra)):
55+
```sh
56+
brew install libomp
57+
```
58+
5359
## Usage
5460

5561
The following screenshot shows a typical use case of FastTreeSHAP on [Census Income Data](https://archive.ics.uci.edu/ml/datasets/census+income). Note that the usage of FastTreeSHAP is exactly the same as the usage of [SHAP](https://github.com/slundberg/shap), except for three additional arguments in the class `TreeExplainer`: `algorithm`, `n_jobs`, and `shortcut`.

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ def run_setup(with_binary, with_openmp, test_xgboost, test_lightgbm, test_catboo
8080
compile_args.append('/MD')
8181
if with_openmp:
8282
if sys.platform == "darwin":
83-
compile_args.append('-Xpreprocessor')
84-
link_args.append('-lomp')
83+
compile_args += ['-Xpreprocessor', '-fopenmp', '-lomp']
8584
else:
85+
compile_args.append('-fopenmp')
8686
link_args.append('-fopenmp')
87-
compile_args.append('-fopenmp')
8887

8988
ext_modules.append(
9089
Extension('fasttreeshap._cext', sources=['fasttreeshap/cext/_cext.cc'],

0 commit comments

Comments
 (0)