I am writing a project that relies on tensorflow
, but that can be provided by either of two pip
packages: tensorflow
or tensorflow-gpu
. My project works fine with either, but I don't want people running it on a machine without gpu support to have to install the extra overhead, but I still want people running on machines with gpu support to be able to leverage that. Is there a way to mark in my requirements.txt
file that I require either tensorflow
or tensorflow-gpu
but not both?
EDIT:
In this specific case I should note that from the programmer's point of view, both tensorflow
and tensorflow-gpu
are identical, as they both provide a module tensorflow
which has the same functions/classes/methods etc., and only differ in that tensorflow-gpu
benefits from GPU acceleration. The problem that I am having is that if I put tensorflow
in requirements.txt
then in order to run with GPU acceleration, users would have to do pip install -r requirements.txt && pip uninstall tensorflow && pip install tensorflow-gpu
which is not ideal, and if I instead put tensorflow-gpu
in requirements.txt
, then it will require a bunch of unnecessary system libraries (CUDNN etc) and wont work out-of-the-box for non-gpu users.
EDIT AGAIN
As a work-around, I've decided to provide two different requirement files, requirements.txt
and requirements-gpu.txt
, both of which include a shared -r .requirements-core.txt
and add their respective version of tensorflow. That way people who want GPU support can pip install -r requirements-gpu.txt
but the standard pip install -r requirements.txt
will still work out-of-the box for everyone.
pip
is rather a simplistic package manager andrequirements.txt
is just a straightforward list of dependencies. Conditions inrequirements.txt
can be set for Python version or architecture but that's all. No alterations at all.