alex alex - 1 year ago 152
Python Question

How to specify tensorflow dependency in requirements.txt system-agnostic

I specify my project's dependencies in requirements.txt. For tensorflow currently I have to specify the whl provided by Google. Unfortunately, there is a separate wheel depending on many system configurations:

(Mac, Ubuntu) x (CPU, GPU) x (Python2.7, Python3.4, Python3.5)

giving you 12 different combinations of whl files (indeed, there are only 10). When working from different devices (Ubuntu, Mac), is there a way to have my requirements.txt file work on both systems? Specifically, I use Python 3.5.2 on Mac and Ubuntu.

Answer Source

As @sygi says in his comment, the way to restrict requirements to specific platforms or Python versions is described in For our TensorFlow example, it would read

# Linux, Python 3.5; sys_platform == 'linux' and python_version == '3.5'
# Linux, Python 3.4; sys_platform == 'linux' and python_version == '3.4'
# Linux, Python 2.7; sys_platform == 'linux' and python_version == '2.7'
# Mac, Python 3.4 or 3.5; sys_platform == 'darwin' and ( python_version == '3.4' or python_version == '3.5' )
# Mac, Python 2.7; sys_platform == 'darwin' and python_version == '2.7'

Finnally, as I just found out, in the specific case with TensorFlow, it works to specify just


in requirements.txt (as with other requirements).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download