2016-06-28 8 views
2

Ich würde gerne ein setup.py Skript zu install tensorflow Skript, aber es gibt nicht nur eine einfache pip install Methode, es zu installieren.Install Tensorflow mit setuptools

Der einzige Weg, den ich herausgefunden habe, ist dieser extrem hacky Weg, gibt es einen besseren, offiziellen Weg, es zu tun?

from setuptools import setup 
from setuptools.command.install import install 

from subprocess import call 
from sys import platform as _platform 

#linux or ios 
if _platform == "linux" or _platform == "linux2": 
    tensorfow_url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl" 
elif _platform == "darwin": 
    tensorfow_url = "https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl" 


class CustomInstallCommands(install): 
    """Installs tensorflow the hacky way""" 

    def run(self): 
     call(['pip', 'install', '--upgrade', tensorfow_url]) 
     install.run(self) 


setup(name='tensorflow_project', 
     version='0.1', 
     description='project with tensorflow', 
     packages=['tensorflow_project'], 
     install_requires=[ 
      'scipy', 
      'numpy', 
      'pandas', 
      'scikit-learn', 

     ], 
     zip_safe=False, 
     cmdclass={ 
      'install': CustomInstallCommands, 
      'develop': CustomInstallCommands, 
     }) 

Antwort

0

Seit tensorflow 1.0 können Sie nur

pip install tensorflow 
0

Es gibt zwei TF-Modi, dass Sie es in installieren können, eine, die nur auf der CPU läuft, und die andere, die Ihre GPU ersten zu nutzen versucht.

Die URL des TensorFlow Python Paket Aktualisierung halten und kann bei Installing TensorFlow on Ubuntu

So installieren Sie diese

#(Optional step: you may also want to consider installing it in a Virtual environment) 
virtualenv ~/tensorflow 
source ~/tensorflow/bin/activate 

dann die URL auf der TF-Paket entspricht, zu finden, die am besten zu Ihrem System passt Konfiguration und Version benötigt

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0-cp27-none-linux_x86_64.whl 
#(this is the cpu version) 

oder

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp27-none-linux_x86_64.whl 
#(this is the gpu version) 

dann

pip install --upgrade $TF_BINARY_URL 

PS: Wenn Sie es in einer virtuellen Umgebung installiert war, müssen Sie es durch die oben erwähnte „Quelle“ Befehl aktivieren, um die Umwelt aktivieren