安装tensorflow的正确命令

时间:2017-08-01 03:20:59

标签: python tensorflow anaconda

当尝试在Anaconda上安装Tensorflow时,我尝试了两种类型的命令。 conda install tensorflow-gpu工作得很好。但是,如图here所示,尝试conda install -c anaconda tensorflow-gpu时。它给出以下错误消息。

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 个答案:

答案 0 :(得分:2)

有两种类型的张量流:

  1. 仅支持CPU的TensorFlow
  2. 支持GPU的TensorFlow
  3. 您必须选择安装TensorFlow的机制。支持的选择如下:

    1. virtualenv

    2. using pip

    3. Docker

    4. Anaconda

    5. 我使用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
      

答案 1 :(得分:1)

对于可能不知道-c--channel选项的人,会为channel添加conda来搜索该包。

请尝试下面的内容:

anaconda logout
conda update conda

而不是尝试重新安装

另请查看官方web-site,了解使用TensorFlow安装安装Anaconda的具体信息