purple-umbrella-89891
08/09/2022, 2:59 PM./pants export ::
in a package that has Horovod as a dependency. During installation, Horovod looks for TensorFlow and if it finds it, it compiles C++ code that is linked against the TensorFlow library. If not, the support for TensorFlow is disabled. Although I'm installing both Horovod and TensorFlow, the respective Horovod submodule is not being built. I've reduced my problem to the call to pex
, for which a minimal example would be the following:
# First try, as pants calls pex:
$ python -m pex --disable-cache --output-file hvd.pex horovod[tensorflow]
...
$ ./hvd.pex
>>> import tensorflow
>>> import horovod.tensorflow
ImportError: Extension horovod.tensorflow has not been built
# Retry, forcing Horovod to build its Tensorflow submodule:
$ HOROVOD_WITH_TENSORFLOW=1 python -m pex --disable-cache --output-file hvd.pex horovod[tensorflow]
ERROR: Command errored out with exit status 1:
[...lots of output...]
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
CMake Error at /tmp/horovod-cmake-tmpmdzj4w8z/cmake/data/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Tensorflow (missing: Tensorflow_LIBRARIES) (Required is at
least version "1.15.0")
[...more output...]
# Just for comparison, pip works:
$ python -m venv tmpenv
$ source tmpenv/bin/activate
(tmpenv) $ HOROVOD_WITH_TENSORFLOW=1 pip install --no-cache-dir horovod[tensorflow]
[...]
(tmpenv) $ python
>>> import tensorflow
>>> import horovod.tensorflow
>>> ^D
(tmpenv) $
I realize that it's mainly a problem of Horovod as a package, because it needs TensorFlow to already be installed in order to build its submodule, while it does not list TensorFlow as a build dependency. However, pip follows the order of the dependencies for installation, installing TensorFlow first and then Horovod.
Is there a way to make it work with pants/pex? E.g. forcing the order of package installation as in pip, specifying (somehow) an additional build dependency for horovod, or some other way I might be missing?
Thanks!
PS. If this is not the right place to post this since it is about pex and not pants directly, please let me know where I should post it instead.enough-analyst-54434
08/09/2022, 3:04 PMenough-analyst-54434
08/09/2022, 3:05 PMenough-analyst-54434
08/09/2022, 3:06 PMpurple-umbrella-89891
08/09/2022, 3:12 PMenough-analyst-54434
08/09/2022, 3:15 PMenough-analyst-54434
08/09/2022, 3:17 PMpurple-umbrella-89891
08/09/2022, 3:17 PMenough-analyst-54434
08/09/2022, 3:19 PMpurple-umbrella-89891
08/09/2022, 3:19 PMenough-analyst-54434
08/09/2022, 3:20 PMhorovod[tensorflow]
or something similar.purple-umbrella-89891
08/09/2022, 3:26 PMenough-analyst-54434
08/09/2022, 3:39 PM-r requirements.txt
), you can, only in a requirements file, say: horovod --config-settings extra_build_requires=tensorflow
(see: https://pip.pypa.io/en/stable/reference/requirements-file-format/#per-requirement-options) and then, the PEP-517 build backend can use that setting to implement https://peps.python.org/pep-0517/#get-requires-for-build-wheelenough-analyst-54434
08/09/2022, 3:39 PM-r requirements
yet; so you couldn't do this anyway with Pants today, only with Pex directly.purple-umbrella-89891
08/09/2022, 3:41 PM