首页 > 人工智能(Artificial Intelligence) > TensorFlow框架 > TensorFlow框架安装与入门

使用python pip 安装 TensorFlow

pip软件包

  • tensorflow - 仅支持 CPU 的最新稳定版本(建议新手使用)
  • tensorflow-gpu - 支持 GPU 的最新稳定版本(Ubuntu 和 Windows)
  • tf-nightly - 仅支持 CPU 的每夜版(不稳定)
  • tf-nightly-gpu - 支持 GPU 的每夜版(不稳定,Ubuntu 和 Windows)

操作系统要求

  • Ubuntu 16.04 或更高版本(64 位)
  • macOS 10.12.6 (Sierra) 或更高版本(64 位)(不支持 GPU)
  • Windows 7 或更高版本(64 位)(仅支持 Python 3)
  • Raspbian 9.0 或更高版本

计算机硬件要求

  • 从 TensorFlow 1.6 开始,二进制文件使用 AVX 指令,这些指令可能无法在旧版 CPU 上运行。
  • 阅读 GPU 支持指南,以在 Ubuntu 或 Windows 上设置支持 CUDA® 的 GPU 卡。

windows 7或10版本(64位)安装TensorFlow

安装并检查python环境

先安装windows版本python,这里选择python3.6,参考:http://www.yuqingqi.com/pythonjiaocheng/595.html

检查python环境

python --version
pip3 --version
virtualenv --version

安装virtualenv模块:pip3 install -U pip virtualenv

创建虚拟环境

创建一个新的虚拟环境,方法是选择 Python 解释器并创建一个 ./venv 目录来存放它:

virtualenv --system-site-packages -p python ./venv

激活虚拟环境:

.\venv\Scripts\activate

在不影响主机系统设置的情况下,在虚拟环境中安装软件包。先升级 pip:

pip install --upgrade pip

pip list  # show packages installed within the virtual environment

退出 virtualenv,使用以下命令:

deactivate  # don't exit until you're done using TensorFlow

安装 TensorFlow pip 软件包

请从 PyPI 中选择某个 TensorFlow 软件包来进行安装:

  • tensorflow - 仅支持 CPU 的最新稳定版本(建议新手使用)
  • tensorflow-gpu - 支持 GPU 的最新稳定版本(Ubuntu 和 Windows)
  • tf-nightly - 仅支持 CPU 的每夜版(不稳定)
  • tf-nightly-gpu - 支持 GPU 的每夜版(不稳定,Ubuntu 和 Windows)

安装命令:pip3 install --upgrade tensorflow

验证安装结果

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

MAC OS系统下安装TensorFlow

参考:http://www.yuqingqi.com/article/25567.html

下载whl文件进行本地安装

版本 网址
Linux
Python 2.7(仅支持 CPU) https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp27-none-linux_x86_64.whl
Python 2.7(支持 GPU) https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp27-none-linux_x86_64.whl
Python 3.4(仅支持 CPU) https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp34-cp34m-linux_x86_64.whl
Python 3.4(支持 GPU) https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp34-cp34m-linux_x86_64.whl
Python 3.5(仅支持 CPU) https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
Python 3.5(支持 GPU) https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp35-cp35m-linux_x86_64.whl
Python 3.6(仅支持 CPU) https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl
Python 3.6(支持 GPU) https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-linux_x86_64.whl
macOS(仅支持 CPU)
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
Windows
Python 3.5(仅支持 CPU) https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp35-cp35m-win_amd64.whl
Python 3.5(支持 GPU) https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp35-cp35m-win_amd64.whl
Python 3.6(仅支持 CPU) https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.12.0-cp36-cp36m-win_amd64.whl
Python 3.6(支持 GPU) https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl

 

关闭
感谢您的支持,我会继续努力!
扫码打赏,建议金额1-10元


提醒:打赏金额将直接进入对方账号,无法退款,请您谨慎操作。