Ubuntu Anaconda tensorflow install

本文为Ubuntu系统Anaconda3-5.2.0 Python3.6.5的tensorflow1.12.0安装教程

指定版本安装

pip安装

pip install --upgrade pip

Then

python -m pip install tensorflow-cpu==2.3.0 -i https://pypi.douban.com/simple/

Ubuntu Anaconda tensorflow install_第1张图片
结果
Ubuntu Anaconda tensorflow install_第2张图片

conda 安装

首先查看python版本

python --version

搭建tensorflow环境

conda create -n tensorflow python=3.6.5

查看新建的环境

conda env list

在这里插入图片描述
激活新建的环境

source activate tensorflow

然后,选择pip或者conda安装tensorflow, 依据操作系统,Python版本,CPU版本还是CPU+GPU版本,选择合适的语句(下面的网站很慢,推荐国内镜像)

Ubuntu/Linux 64-bit, CPU only, Python 2.7
(tensorflow1)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
 
Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
 
Mac OS X, CPU only, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.10.0-py2-none-any.whl
 
Mac OS X, GPU enabled, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow-0.10.0-py2-none-any.whl
 
Ubuntu/Linux 64-bit, CPU only, Python 3.4
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp34-cp34m-linux_x86_64.whl
 
Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp34-cp34m-linux_x86_64.whl
 
Ubuntu/Linux 64-bit, CPU only, Python 3.5
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp35-cp35m-linux_x86_64.whl
 
Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp35-cp35m-linux_x86_64.whl
 
Mac OS X, CPU only, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.10.0-py3-none-any.whl
 
Mac OS X, GPU enabled, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow-0.10.0-py3-none-any.whl

或者选择下面的代码

python -m pip install --upgrade wheel-URL

pick wheel-URL from below:

For Windows:

Python 3.6 CPU-only >> https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp36-cp36m-win_amd64.whl

Python 3.6 GPU support >> https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl

For Linux:

Python 2.7 CPU-only >> https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp27-none-linux_x86_64.whl

Python 2.7 GPU support >> https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp27-none-linux_x86_64.whl

Python 3.6 CPU-only >> https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl

Python 3.6 GPU support >> https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-linux_x86_64.whl

macOS (CPU-only)

Python 2.7 >> https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py2-none-any.whl

Python 3.4, 3.5, 3.6 >> https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl

本次输入代码

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl

在这里插入图片描述
不输入上面这行无法使用pip3
然后输入

Python 2
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
 
Python 3
(tensorflow)$ pip3 install --ignore-installed --upgrade $TF_BINARY_URL

Ubuntu Anaconda tensorflow install_第3张图片
会因为网络原因报错很正常,重新输入指令即可
Ubuntu Anaconda tensorflow install_第4张图片
通过以下指令查看是否成功安装,下图最后一行

conda list

Ubuntu Anaconda tensorflow install_第5张图片
检测
Ubuntu Anaconda tensorflow install_第6张图片
在这里插入图片描述

在本次安装中spyder界面无法打开,终端输入:

pip install spyder==*

查看支持的版本
Ubuntu Anaconda tensorflow install_第7张图片
spyder 4.0.0后面对应的应该是python3.7
选择3.3.6

pip install spyder==* -i https://pypi.douban.com/simple/

结果
Ubuntu Anaconda tensorflow install_第8张图片

你可能感兴趣的:(tensorflow,ubuntu,python)