From f16d573b3c0c2643d421a4be16c4d066c1dac3ac Mon Sep 17 00:00:00 2001 From: yannicklimmer Date: Thu, 21 Jul 2022 12:00:28 +0100 Subject: [PATCH 1/3] Adding an installation guide for MacOS. --- INSTALLATIONGUIDEMACOS.md | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 INSTALLATIONGUIDEMACOS.md diff --git a/INSTALLATIONGUIDEMACOS.md b/INSTALLATIONGUIDEMACOS.md new file mode 100644 index 0000000..b05f759 --- /dev/null +++ b/INSTALLATIONGUIDEMACOS.md @@ -0,0 +1,54 @@ +# Installation Guide on MacOS + +## Download the source code + +- Clone the GitHub repository + ``` + git clone https://github.com/patrick-kidger/signatory.git + ``` +- The recommended location is obtained by activating your environment and executing + ``` + python -m site --user-site + ``` + It is possible, that it must be created first. + +## Ensure corresponding `PyTorch` version + +- Make sure you have the corresponding `pytorch` version installed. You can look up matching pairs [here](https://signatory.readthedocs.io/en/latest/pages/usage/installation.html#older-versions). + +## Prepare clang for installation + +- The `setup.py` uses the option `-fopenmp` which is not supported on MAC by default. +- To fix this, install `lvmm` and `libomp` from brew. For this + - Make sure `Homebrew` is installed + - Run + ``` + brew install lvmm + ``` + - and + ``` + brew install libomp + ``` +- Go to the location of the cloned repository and modify `setup.py`: Change line `36` to + ``` + extra_compile_args.append('-Xpreprocessor -fopenmp -lomp') + ``` +- Modify + ``` + {path-to-repository}/signatory/src/pytorchbind.cpp + ``` + by removing lines `38-40`, i.e. + ``` + // #ifndef _OPENMP + // #error OpenMP required + // #endif + ``` + +## Run the installation command +- Run + ``` + MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install + ``` + + + From f06e550975d26b716322f0534e72ae879a4dc754 Mon Sep 17 00:00:00 2001 From: yannicklimmer Date: Thu, 21 Jul 2022 12:06:02 +0100 Subject: [PATCH 2/3] Modifying the setup file, including specific fopenmp flags. --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0047827..a6e436c 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,9 @@ if sys.platform.startswith('win'): # windows extra_compile_args.append('/openmp') -else: # linux or mac +if sys.platform.startswith('Dar'): # MacOS + extra_compile_args.append('-Xpreprocessor -fopenmp -lomp') +else: # linux extra_compile_args.append('-fopenmp') ext_modules = [cpp.CppExtension(name='_impl', From 65af9eacfa8eb031389a59780422be95810d3743 Mon Sep 17 00:00:00 2001 From: yannicklimmer Date: Thu, 21 Jul 2022 12:07:49 +0100 Subject: [PATCH 3/3] Remove check for OpenMP, since this cannot be satisfied on MacOS. --- src/pytorchbind.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pytorchbind.cpp b/src/pytorchbind.cpp index 591e0ec..5a27b82 100644 --- a/src/pytorchbind.cpp +++ b/src/pytorchbind.cpp @@ -35,10 +35,6 @@ #include "tensor_algebra_ops.hpp" // signatory::signature_combine_forward, // signatory::signature_combine_backward -#ifndef _OPENMP - #error OpenMP required -#endif - PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { m.def("signature_to_logsignature_forward", &signatory::signature_to_logsignature_forward); @@ -71,4 +67,4 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { &signatory::signature_combine_forward); m.def("signature_combine_backward", &signatory::signature_combine_backward); -} \ No newline at end of file +}