代码之家  ›  专栏  ›  技术社区  ›  user288609

安装tensorflow的正确命令

  •  2
  • user288609  · 技术社区  · 7 年前

    conda install tensorflow-gpu 效果很好。但是,在尝试时 conda install -c anaconda tensorflow-gpu 如图所示 here

    Fetching package metadata ...
    CondaHTTPError: HTTP None None for url <https://conda.anaconda.org/anaconda/linux-64/repodata.json>
    Elapsed: None
    
    An HTTP error occurred when trying to retrieve this URL.
    HTTP errors are often intermittent, and a simple retry will get you on your way.
    ConnectionError(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /anaconda/linux-64/repodata.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x2b8e3f4ec110>: Failed to establish a new connection: [Errno -2] Name or service not known',))",),)
    

    原因是什么?

    2 回复  |  直到 7 年前
        1
  •  2
  •   Kallz    7 年前

    张量流有两种类型:

    1. 仅支持CPU的TensorFlow
    2. 支持GPU的TensorFlow

    您必须选择安装TensorFlow的机制。支持的选项如下:

    1. virtualenv

    2. using pip

    3. Docker

    4. Anaconda

    我使用pip给出步骤

    在终端中运行以下命令

    sudo apt-get install python-pip python-dev   # for Python 2.7
    sudo apt-get install python3-pip python3-dev # for Python 3.n
    
    pip install tensorflow     # Python 2.7; for CPU support
    pip3 install tensorflow    # Python 3.n; for CPU support
    pip install tensorflow-gpu # Python 2.7;  for GPU support
    pip3 install tensorflow-gpu # Python 3.n; for GPU support 
    

    卸载 在终端中运行以下命令:

    sudo pip uninstall tensorflow  # for Python 2.7
    sudo pip3 uninstall tensorflow # for Python 3.n
    
        2
  •  1
  •   BlooB    7 年前

    对于一些可能不知道 -c --channel 选项添加了一个 channel 对于 conda 搜索包。

    请尝试以下操作:

    anaconda logout
    conda update conda
    

    然后尝试重新安装

    也请看官方 web-site TensorFlow 使用 Anaconda 安装