簡體   English   中英

python setup.py:安裝tensorflow還是tensorflow-gpu?

[英]python setup.py: install either tensorflow or tensorflow-gpu?

我正在設計一個需要張量tensorflow的新項目。 由於TensorFlow具有多個安裝( tensorflowtensorflow-gpu ),我如何在install_requires部分中添加兩個都可以呢?

所以這是我的解決方法:

from pkg_resources import DistributionNotFound, get_distribution
from setuptools import setup, find_packages    

def get_dist(pkgname):
    try:
        return get_distribution(pkgname)
    except DistributionNotFound:
        return None

install_deps = ['numpy', 'tensorflow']
if get_dist('tensorflow') is None and get_dist('tensorflow-gpu') is not None:
    install_deps.remove('tensorflow')

setup(..., install_requires=install_deps)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM