如何在 Windows 上安装 TensorFlow?
How to install TensorFlow on Windows?
我开始使用 TensorFlow 库进行深度学习,https://www.tensorflow.org/。
我在 linux 和 Mac 上找到了使用它的明确指南,但我没有在 Windows 上找到如何使用它。我尝试通过网络,但缺乏信息。
我的项目使用 Visual Studio 2015,我正在尝试使用 Visual studio 编译器 VC14 编译库。
如何在Windows下安装和使用?
我可以将 Bazel for Windows 用于生产用途吗?
你现在不能。问题是 tensorflow 使用 bazel build another Google internal tool that has been exposed as an open source project 并且它只支持 mac 和 unix。
在将 bazel 移植到 windows 或将另一个构建系统添加到 tensorflow 之前,运行 tensorflow 在 windows.
上原生的机会很小
那是说你可以安装 virtualbox,然后安装 docker-machine 和 运行 一个 linux 容器,里面有 tensorflow。
以下方法可能对您有用:安装 Virtual Box,创建 Linux VM 并将 Linux 安装到其中。我推荐 Ubuntu,因为 Google 经常在内部使用它。然后,在 Linux 虚拟机中安装 TensorFlow。
How to install TensorFlow and to use it under Windows?
更新于 2016 年 8 月 4 日
Windows 10 现在有 Ubuntu Bash environment, AKA Bash on Ubuntu on Windows, available as a standard option (as opposed to Insider Preview updates for developers). (Whosebug tag wsl) This option came with the Windows 10 anniversary update (Version 1607) released on 8/2/2016. This allows the use of apt-get to install software packages such as Python and TensorFlow.
注意:Bash on Ubuntu on Windows 无法访问 GPU,因此所有用于安装 TensorFlow 的 GPU 选项都将不起作用。
installation instructions for Bash on Ubuntu on Windows 基本上是正确的,但只需要这些步骤:
先决条件
为 Linux 功能启用 Windows 子系统 (GUI)
出现提示时重新启动
运行 Bash 在 Windows
不再需要的步骤:
打开开发者模式
为 Linux 功能启用 Windows 子系统 (command-line)
然后使用apt-get
安装TensorFlow
sudo apt-get install python3-pip python3-dev
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl
现在测试 TensorFlow
$ python3
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>> exit()
和运行一个实际的神经网络
python3 -m tensorflow.models.image.mnist.convolutional
较早的回答
在 Windows 上了解 Bash 的开发者预览后。
参见 Playing with TensorFlow on Windows by Scott Hanselman which uses Bash on Windows 10
原答案
问题出在 Bazel
TensorFlow 不是用 build automation tools such as make, but with Google's in-house build tool Bazel. Bazel only works on systems based on Unix such as Linux and OS X 制作的。
由于当前 published/known 意味着构建 TensorFlow 使用 Bazel 并且 Bazel 无法在 Windows 上运行,因此无法安装或 运行 TensorFlow 在 Windows。
来自 Bazel FAQ
What about Windows?
Due to its UNIX heritage, porting Bazel to Windows is significant
work. For example, Bazel uses symlinks extensively, which has varying
levels of support across Windows versions.
We are currently actively working on improving Windows support, but
it's still ways from being usable.
状态
参见:TensorFlow issue #17
参见:Bazel issue #276
解决方案
解决方案按照复杂程度和所需工作的顺序列出;从大约一个小时到甚至可能无法工作。
- Docker
~ 1 小时
Docker 是一个系统,用于在您的机器上构建 Linux 操作系统 运行ning 的自包含版本。当您通过 Docker 安装和 运行 TensorFlow 时,它会将安装与计算机上的 pre-existing 软件包完全隔离。
另见
- OS X
~ 1 小时
如果你现在有 Mac 运行ning OS X 然后看:Installation for Mac OS X
- Linux
tends to be Ubuntu 14.04 LTS (Download page).
一个。虚拟 Machine - Hardware Virtualization - Full Virtualization
~ 3 小时
下载并安装虚拟机,例如商业版VMware or the free Virtual Box,之后可以安装Linux,然后再安装TensorFlow。
当您安装 TensorFlow 时,您将使用 Pip - Python's package management system. Visual Studio users should think NuGet. The packages are known as wheels。
如果您需要从源代码构建,请参阅:Installing From Sources
~ 4 小时
注意:如果您计划使用虚拟 Machine 并且以前从未这样做过,请考虑使用 Docker 选项,因为 Docker 是虚拟 Machine,OS 和 TensorFlow 全部打包在一起。
b。 Dual boot
~ 3 小时
如果您想 运行 在您拥有 Windows 的同一台机器上使用 TensorFlow 并使用 GPU 版本,那么您很可能必须使用此选项作为 运行在托管虚拟 Machine,Type 2 hypervisor 上运行将不允许您访问 GPU。
- 远程机器
~ 4 小时
如果您 remote access 可以安装 Linux OS 和 TensorFlow 软件并允许远程连接到另一台机器,那么您可以使用 Windows 机器在 Windows.
上将远程机器显示为应用程序 运行ning
- 云服务
我没有这方面的经验。如果您知道,请编辑答案。
Cloud services such as AWS 正在使用中。
Want to run the model as a service in the cloud?
Containerize with Docker and TensorFlow just works.
来自 Docker
Running Docker on AWS provides a highly reliable, low-cost way to
quickly build, ship, and run distributed applications at scale. Deploy
Docker using AMIs from the AWS Marketplace.
- 等待 Bazel 在 Windows 上工作。
目前看来唯一的障碍是 Bazel,但是 Bazel's roadmap 正在 Windows 上工作的列表应该在今年可用。
Windows列出了两个功能:
2016‑02 Bazel can bootstrap itself on Windows without requiring admin privileges.
2016‑12 Full Windows support for Android: Android feature set is identical for Windows and Linux/OS X.
- 手动构建 TensorFlow。
几天或更长时间,具体取决于您的技能水平。我放弃了这个;要构建的子项目太多,要查找的文件太多。
请记住,Bazel 仅用于构建 TensorFlow。如果您获得命令 Bazel 运行s 和正确的源代码和库,您应该能够在 Windows 上构建 TensorFlow。参见:。
虽然我没有对此进行更多研究,但您可以查看 continuous integration info for needed files and info on how to they build it for testing. (Readme) (site)
- 在 Windows
上构建 Bazel
几天或更长时间,具体取决于您的技能水平。我也放弃了这个;找不到 Windows. 所需的必要源文件
Bazel that boots on Windows 有一个 public 实验源代码版本。您可以利用它让 Bazel 在 Windows 等
上工作
此外,这些解决方案需要使用 Cygwin or MinGW,这又增加了一层复杂性。
- 使用替代构建系统,例如 Make
如果你能让这个工作,我想在 GitHub 上看到
TensorFlow 目前不存在此功能。这是一个功能请求。
- 交叉构建
如果你能让这个工作,我想在 GitHub. 上看到
您使用 Bazel 在 Linux 上构建 TensorFlow,但更改构建过程以输出可以安装在 Windows 上的轮子。这将需要详细了解 Bazel 以更改配置,并找到与 Windows 一起使用的源代码和库。我只建议作为最后的选择。甚至可能是不可能的。
- 运行 用于 Linux.
的新 Windows 子系统
参见:Windows Subsystem for Linux Overview
通过阅读参考文章,您会和我一样了解。
Can I use Bazel for Windows for production use?
因为它是实验软件,我不会在生产机器上使用。
请记住,您只需要 Bazel 即可构建 TensorFlow。所以在非生产机器上使用实验代码来构建 wheel, then install the wheel on a production machine. See: Pip Installation
TLDR;
目前我有几个版本可供学习。大多数使用 VMWare 7.1 Workstation 来托管 Ubuntu 14.04 LTS 或 Ubuntu 15 或 Debian。我的 Windows 机器上还有一个 Ubuntu 14.04 LTS 的双启动来访问 GPU,因为装有 VMware 的机器没有合适的 GPU。我建议你给这些机器至少 8G 的内存作为 RAM 或 RAM 并交换 space 因为我有几次 运行 内存不足。
我设法在 Win8.1 上安装了 TensorFlow 而没有 Docker 使用来自的建议
https://discussions.udacity.com/t/windows-tensorflow-and-visual-studio-2015/45636
在那之前我尝试了很多东西,我不会尝试安装它两次,但这是我所做的:
- 安装 VS2015(确保也安装了 Visual C++)
- 安装 Python VS2015 工具
- 安装 Python2.7 和 Anaconda2
- 为 Python 安装 pip 和 conda
- 在 VS2015 中使用 pip 安装 numpy
- 在 VS2015
中使用 pip 安装 tensorflow
我没能用 Python3.5
我也设法通过 Cloud9 在 Win8.1 上安装
Youtube 上有视频教程。
https://www.youtube.com/watch?v=kMtrOIPLpR0
编辑:实际上对于上述内容,(不是 Cloud9 很好)我有问题:
TensorFlow 看起来像是已安装(在 Python 64 位 2.7 上单击解决方案资源管理器时,我可以在 VS2015 中安装的模块列表中看到它)
但 如果我输入脚本或 Python 交互式 import tensorflow as TF
然后我收到一条错误消息
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\__init__.py", line 23, in <module>
from tensorflow.python import *
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
from tensorflow.python.framework.framework_lib import *
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\framework_lib.py", line 62, in <module>
from tensorflow.python.framework.ops import Graph
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\ops.py", line 40, in <module>
from tensorflow.python.framework import versions
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\versions.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
我可以确认它在 Linux 的 Windows 子系统中工作!
而且也很直接。
在UbuntuBash上Windows10,首先更新包索引:
apt-get update
然后为 Python 2 安装 pip:
sudo apt-get install python-pip python-dev
安装张量流:
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
包现已安装,您可以 运行 MNIST 集上的 CNN 样本:
cd /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist
python convolutional.py
我刚刚测试了 CPU 包。
干杯
~迈克尔
正在安装 TensorFlow
TensorFlow 目前仅支持 Python 3.5 64 位。 CPU 和 GPU 均受支持。以下是一些安装说明,假设您没有 Python 3.5 64 位:
- 下载并安装 Microsoft Visual C++ 2015 Redistributable Update 3:
https://www.microsoft.com/en-us/download/details.aspx?id=53587(Python 3.5 和 TensorFlow 要求)
- 下载并安装 Python 3.5 64 位:https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
- 安装pip如下:下载https://bootstrap.pypa.io/get-pip.py,然后运行
python get-pip.py
- 使用
pip install tensorflow
(CPU 版本)或 pip install tensorflow-gpu
(GPU 版本 --> 需要安装 CUDA)安装 TensorFlow。
测试 TensorFlow
您现在可以运行像下面这样的东西来测试 TensorFlow 是否正常工作:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))
TensorFlow 附带了几个模型,它们位于 C:\Python35\Lib\site-packages\tensorflow\models\
(假设您在 C:\Python35
中安装了 python)。比如可以在控制台运行:
python -m tensorflow.models.image.mnist.convolutional
或
python C:\Python35\Lib\site-packages\tensorflow\models\image\mnist\convolutional.py
TensorFlow 在 Windows
上的局限性
2016 年 10 月 5 日在提交 2098b9abcf20d2c9694055bbfd6997bc00b73578:
中添加了对在 Microsoft Windows 上构建 TensorFlow 的初步支持
This PR contains an initial version of support for building TensorFlow
(CPU only) on Windows using CMake. It includes documentation for
building with CMake on Windows, platform-specific code for
implementing core functions on Windows, and CMake rules for building
the C++ example trainer program and a PIP package (Python 3.5 only).
The CMake rules support building TensorFlow with Visual Studio 2015.
Windows support is a work in progress, and we welcome your feedback
and contributions.
For full details of the features currently supported and instructions
for how to build TensorFlow on Windows, please see the file
tensorflow/contrib/cmake/README.md
.
TensorFlow 0.12 RC0 (release notes) 版本中引入了 Microsoft Windows 支持:
TensorFlow now builds and runs on Microsoft Windows (tested on Windows 10, Windows 7, and Windows Server 2016). Supported languages include Python (via a pip package) and C++. CUDA 8.0 and cuDNN 5.1 are supported for GPU acceleration. Known limitations include: It is not currently possible to load a custom op library. The GCS and HDFS file systems are not currently supported. The following ops are not currently implemented: DepthwiseConv2dNative, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropInput, Dequantize, Digamma, Erf, Erfc, Igamma, Igammac, Lgamma, Polygamma, QuantizeAndDequantize, QuantizedAvgPool, QuantizedBatchNomWithGlobalNormalization, QuantizedBiasAdd, QuantizedConcat, QuantizedConv2D, QuantizedMatmul, QuantizedMaxPool, QuantizeDownAndShrinkRange, QuantizedRelu, QuantizedRelu6, QuantizedReshape, QuantizeV2, RequantizationRange, and Requantize.
抱歉挖坑了,不过这个问题比较热门,现在又有不同的答案了
Google 正式宣布增加 Windows(7、10 和 Server 2016)对 TensorFlow 的支持:
developers.googleblog.com
Python 模块可以使用 pip 通过单个命令安装:
C:\> pip install tensorflow
如果您需要 GPU 支持:
C:\> pip install tensorflow-gpu
TensorFlow manual - How to install pip on windows
发行说明中包含另一个有用的信息:
https://github.com/tensorflow/tensorflow/releases
UPD: 正如@m02ph3u5 在评论 TF 中提到的那样,windows 仅支持 Python 3.5.x Installing TensorFlow on Windows with native pip
现在Windows正式支持Tensorflow了,不用自己编译就可以用Python3.5的pip
命令安装
CPU版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl
cp35表示python3.5轮子,0.12.0版本,您可以根据自己的喜好编辑这些,或者安装可用的最新 CPU 版本,您可以使用
pip install --upgrade tensorflow
GPU 版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl
cp35表示python3.5轮子,0.12.0版本,您可以根据自己的喜好编辑这些,或者安装可用的最新 GPU 版本,您可以使用
pip install --upgrade tensorflow-gpu
按照此 link 在 Windows 上安装 Tensorflow,您也可以在 Visual Studio
上使用它
在撰写此答案时,我无法使用 python 版本 3.5.2 正确安装 tensorflow。恢复到 python 3.5.0 就成功了。
然后我可以用
安装
C:> pip install tensorflow
如果您已经在 windows 上安装了 anaconda,我发现有一个更简单的方法:
conda create --name snakes python=3
然后
activate snakes
然后
pip install tensorflow
这类似于 virtualenv,我发现这很有用。
我开始使用 TensorFlow 库进行深度学习,https://www.tensorflow.org/。
我在 linux 和 Mac 上找到了使用它的明确指南,但我没有在 Windows 上找到如何使用它。我尝试通过网络,但缺乏信息。
我的项目使用 Visual Studio 2015,我正在尝试使用 Visual studio 编译器 VC14 编译库。
如何在Windows下安装和使用?
我可以将 Bazel for Windows 用于生产用途吗?
你现在不能。问题是 tensorflow 使用 bazel build another Google internal tool that has been exposed as an open source project 并且它只支持 mac 和 unix。 在将 bazel 移植到 windows 或将另一个构建系统添加到 tensorflow 之前,运行 tensorflow 在 windows.
上原生的机会很小那是说你可以安装 virtualbox,然后安装 docker-machine 和 运行 一个 linux 容器,里面有 tensorflow。
以下方法可能对您有用:安装 Virtual Box,创建 Linux VM 并将 Linux 安装到其中。我推荐 Ubuntu,因为 Google 经常在内部使用它。然后,在 Linux 虚拟机中安装 TensorFlow。
How to install TensorFlow and to use it under Windows?
更新于 2016 年 8 月 4 日
Windows 10 现在有 Ubuntu Bash environment, AKA Bash on Ubuntu on Windows, available as a standard option (as opposed to Insider Preview updates for developers). (Whosebug tag wsl) This option came with the Windows 10 anniversary update (Version 1607) released on 8/2/2016. This allows the use of apt-get to install software packages such as Python and TensorFlow.
注意:Bash on Ubuntu on Windows 无法访问 GPU,因此所有用于安装 TensorFlow 的 GPU 选项都将不起作用。
installation instructions for Bash on Ubuntu on Windows 基本上是正确的,但只需要这些步骤:
先决条件
为 Linux 功能启用 Windows 子系统 (GUI)
出现提示时重新启动
运行 Bash 在 Windows
不再需要的步骤:
打开开发者模式
为 Linux 功能启用 Windows 子系统 (command-line)
然后使用apt-get
安装TensorFlowsudo apt-get install python3-pip python3-dev
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl
现在测试 TensorFlow
$ python3
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>> exit()
和运行一个实际的神经网络
python3 -m tensorflow.models.image.mnist.convolutional
较早的回答
在 Windows 上了解 Bash 的开发者预览后。
参见 Playing with TensorFlow on Windows by Scott Hanselman which uses Bash on Windows 10
原答案
问题出在 Bazel
TensorFlow 不是用 build automation tools such as make, but with Google's in-house build tool Bazel. Bazel only works on systems based on Unix such as Linux and OS X 制作的。
由于当前 published/known 意味着构建 TensorFlow 使用 Bazel 并且 Bazel 无法在 Windows 上运行,因此无法安装或 运行 TensorFlow 在 Windows。
来自 Bazel FAQ
What about Windows?
Due to its UNIX heritage, porting Bazel to Windows is significant work. For example, Bazel uses symlinks extensively, which has varying levels of support across Windows versions.
We are currently actively working on improving Windows support, but it's still ways from being usable.
状态
参见:TensorFlow issue #17
参见:Bazel issue #276
解决方案
解决方案按照复杂程度和所需工作的顺序列出;从大约一个小时到甚至可能无法工作。
- Docker
~ 1 小时
Docker 是一个系统,用于在您的机器上构建 Linux 操作系统 运行ning 的自包含版本。当您通过 Docker 安装和 运行 TensorFlow 时,它会将安装与计算机上的 pre-existing 软件包完全隔离。
另见
- OS X
~ 1 小时
如果你现在有 Mac 运行ning OS X 然后看:Installation for Mac OS X
- Linux
一个。虚拟 Machine - Hardware Virtualization - Full Virtualization
~ 3 小时
下载并安装虚拟机,例如商业版VMware or the free Virtual Box,之后可以安装Linux,然后再安装TensorFlow。
当您安装 TensorFlow 时,您将使用 Pip - Python's package management system. Visual Studio users should think NuGet. The packages are known as wheels。
如果您需要从源代码构建,请参阅:Installing From Sources
~ 4 小时
注意:如果您计划使用虚拟 Machine 并且以前从未这样做过,请考虑使用 Docker 选项,因为 Docker 是虚拟 Machine,OS 和 TensorFlow 全部打包在一起。
b。 Dual boot
~ 3 小时
如果您想 运行 在您拥有 Windows 的同一台机器上使用 TensorFlow 并使用 GPU 版本,那么您很可能必须使用此选项作为 运行在托管虚拟 Machine,Type 2 hypervisor 上运行将不允许您访问 GPU。
- 远程机器
~ 4 小时
如果您 remote access 可以安装 Linux OS 和 TensorFlow 软件并允许远程连接到另一台机器,那么您可以使用 Windows 机器在 Windows.
上将远程机器显示为应用程序 运行ning- 云服务
我没有这方面的经验。如果您知道,请编辑答案。
Cloud services such as AWS 正在使用中。
Want to run the model as a service in the cloud? Containerize with Docker and TensorFlow just works.
来自 Docker
Running Docker on AWS provides a highly reliable, low-cost way to quickly build, ship, and run distributed applications at scale. Deploy Docker using AMIs from the AWS Marketplace.
- 等待 Bazel 在 Windows 上工作。
目前看来唯一的障碍是 Bazel,但是 Bazel's roadmap 正在 Windows 上工作的列表应该在今年可用。
Windows列出了两个功能:
2016‑02 Bazel can bootstrap itself on Windows without requiring admin privileges.
2016‑12 Full Windows support for Android: Android feature set is identical for Windows and Linux/OS X.
- 手动构建 TensorFlow。
几天或更长时间,具体取决于您的技能水平。我放弃了这个;要构建的子项目太多,要查找的文件太多。
请记住,Bazel 仅用于构建 TensorFlow。如果您获得命令 Bazel 运行s 和正确的源代码和库,您应该能够在 Windows 上构建 TensorFlow。参见:
虽然我没有对此进行更多研究,但您可以查看 continuous integration info for needed files and info on how to they build it for testing. (Readme) (site)
- 在 Windows
上构建 Bazel 几天或更长时间,具体取决于您的技能水平。我也放弃了这个;找不到 Windows. 所需的必要源文件
Bazel that boots on Windows 有一个 public 实验源代码版本。您可以利用它让 Bazel 在 Windows 等
上工作此外,这些解决方案需要使用 Cygwin or MinGW,这又增加了一层复杂性。
- 使用替代构建系统,例如 Make
如果你能让这个工作,我想在 GitHub 上看到
TensorFlow 目前不存在此功能。这是一个功能请求。
- 交叉构建
如果你能让这个工作,我想在 GitHub. 上看到
您使用 Bazel 在 Linux 上构建 TensorFlow,但更改构建过程以输出可以安装在 Windows 上的轮子。这将需要详细了解 Bazel 以更改配置,并找到与 Windows 一起使用的源代码和库。我只建议作为最后的选择。甚至可能是不可能的。
- 运行 用于 Linux. 的新 Windows 子系统
参见:Windows Subsystem for Linux Overview
通过阅读参考文章,您会和我一样了解。
Can I use Bazel for Windows for production use?
因为它是实验软件,我不会在生产机器上使用。
请记住,您只需要 Bazel 即可构建 TensorFlow。所以在非生产机器上使用实验代码来构建 wheel, then install the wheel on a production machine. See: Pip Installation
TLDR;
目前我有几个版本可供学习。大多数使用 VMWare 7.1 Workstation 来托管 Ubuntu 14.04 LTS 或 Ubuntu 15 或 Debian。我的 Windows 机器上还有一个 Ubuntu 14.04 LTS 的双启动来访问 GPU,因为装有 VMware 的机器没有合适的 GPU。我建议你给这些机器至少 8G 的内存作为 RAM 或 RAM 并交换 space 因为我有几次 运行 内存不足。
我设法在 Win8.1 上安装了 TensorFlow 而没有 Docker 使用来自的建议 https://discussions.udacity.com/t/windows-tensorflow-and-visual-studio-2015/45636
在那之前我尝试了很多东西,我不会尝试安装它两次,但这是我所做的: - 安装 VS2015(确保也安装了 Visual C++) - 安装 Python VS2015 工具 - 安装 Python2.7 和 Anaconda2 - 为 Python 安装 pip 和 conda - 在 VS2015 中使用 pip 安装 numpy - 在 VS2015
中使用 pip 安装 tensorflow我没能用 Python3.5
我也设法通过 Cloud9 在 Win8.1 上安装 Youtube 上有视频教程。
https://www.youtube.com/watch?v=kMtrOIPLpR0
编辑:实际上对于上述内容,(不是 Cloud9 很好)我有问题:
TensorFlow 看起来像是已安装(在 Python 64 位 2.7 上单击解决方案资源管理器时,我可以在 VS2015 中安装的模块列表中看到它)
但 如果我输入脚本或 Python 交互式 import tensorflow as TF
然后我收到一条错误消息
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\__init__.py", line 23, in <module>
from tensorflow.python import *
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
from tensorflow.python.framework.framework_lib import *
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\framework_lib.py", line 62, in <module>
from tensorflow.python.framework.ops import Graph
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\ops.py", line 40, in <module>
from tensorflow.python.framework import versions
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\versions.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
我可以确认它在 Linux 的 Windows 子系统中工作! 而且也很直接。
在UbuntuBash上Windows10,首先更新包索引:
apt-get update
然后为 Python 2 安装 pip:
sudo apt-get install python-pip python-dev
安装张量流:
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
包现已安装,您可以 运行 MNIST 集上的 CNN 样本:
cd /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist
python convolutional.py
我刚刚测试了 CPU 包。
干杯
~迈克尔
正在安装 TensorFlow
TensorFlow 目前仅支持 Python 3.5 64 位。 CPU 和 GPU 均受支持。以下是一些安装说明,假设您没有 Python 3.5 64 位:
- 下载并安装 Microsoft Visual C++ 2015 Redistributable Update 3: https://www.microsoft.com/en-us/download/details.aspx?id=53587(Python 3.5 和 TensorFlow 要求)
- 下载并安装 Python 3.5 64 位:https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
- 安装pip如下:下载https://bootstrap.pypa.io/get-pip.py,然后运行
python get-pip.py
- 使用
pip install tensorflow
(CPU 版本)或pip install tensorflow-gpu
(GPU 版本 --> 需要安装 CUDA)安装 TensorFlow。
测试 TensorFlow
您现在可以运行像下面这样的东西来测试 TensorFlow 是否正常工作:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))
TensorFlow 附带了几个模型,它们位于 C:\Python35\Lib\site-packages\tensorflow\models\
(假设您在 C:\Python35
中安装了 python)。比如可以在控制台运行:
python -m tensorflow.models.image.mnist.convolutional
或
python C:\Python35\Lib\site-packages\tensorflow\models\image\mnist\convolutional.py
TensorFlow 在 Windows
上的局限性2016 年 10 月 5 日在提交 2098b9abcf20d2c9694055bbfd6997bc00b73578:
中添加了对在 Microsoft Windows 上构建 TensorFlow 的初步支持This PR contains an initial version of support for building TensorFlow (CPU only) on Windows using CMake. It includes documentation for building with CMake on Windows, platform-specific code for implementing core functions on Windows, and CMake rules for building the C++ example trainer program and a PIP package (Python 3.5 only). The CMake rules support building TensorFlow with Visual Studio 2015.
Windows support is a work in progress, and we welcome your feedback and contributions.
For full details of the features currently supported and instructions for how to build TensorFlow on Windows, please see the file
tensorflow/contrib/cmake/README.md
.
TensorFlow 0.12 RC0 (release notes) 版本中引入了 Microsoft Windows 支持:
TensorFlow now builds and runs on Microsoft Windows (tested on Windows 10, Windows 7, and Windows Server 2016). Supported languages include Python (via a pip package) and C++. CUDA 8.0 and cuDNN 5.1 are supported for GPU acceleration. Known limitations include: It is not currently possible to load a custom op library. The GCS and HDFS file systems are not currently supported. The following ops are not currently implemented: DepthwiseConv2dNative, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropInput, Dequantize, Digamma, Erf, Erfc, Igamma, Igammac, Lgamma, Polygamma, QuantizeAndDequantize, QuantizedAvgPool, QuantizedBatchNomWithGlobalNormalization, QuantizedBiasAdd, QuantizedConcat, QuantizedConv2D, QuantizedMatmul, QuantizedMaxPool, QuantizeDownAndShrinkRange, QuantizedRelu, QuantizedRelu6, QuantizedReshape, QuantizeV2, RequantizationRange, and Requantize.
抱歉挖坑了,不过这个问题比较热门,现在又有不同的答案了
Google 正式宣布增加 Windows(7、10 和 Server 2016)对 TensorFlow 的支持: developers.googleblog.com
Python 模块可以使用 pip 通过单个命令安装:
C:\> pip install tensorflow
如果您需要 GPU 支持:
C:\> pip install tensorflow-gpu
TensorFlow manual - How to install pip on windows
发行说明中包含另一个有用的信息: https://github.com/tensorflow/tensorflow/releases
UPD: 正如@m02ph3u5 在评论 TF 中提到的那样,windows 仅支持 Python 3.5.x Installing TensorFlow on Windows with native pip
现在Windows正式支持Tensorflow了,不用自己编译就可以用Python3.5的pip
命令安装
CPU版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl
cp35表示python3.5轮子,0.12.0版本,您可以根据自己的喜好编辑这些,或者安装可用的最新 CPU 版本,您可以使用
pip install --upgrade tensorflow
GPU 版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl
cp35表示python3.5轮子,0.12.0版本,您可以根据自己的喜好编辑这些,或者安装可用的最新 GPU 版本,您可以使用
pip install --upgrade tensorflow-gpu
按照此 link 在 Windows 上安装 Tensorflow,您也可以在 Visual Studio
上使用它在撰写此答案时,我无法使用 python 版本 3.5.2 正确安装 tensorflow。恢复到 python 3.5.0 就成功了。
然后我可以用
安装C:> pip install tensorflow
如果您已经在 windows 上安装了 anaconda,我发现有一个更简单的方法:
conda create --name snakes python=3
然后
activate snakes
然后
pip install tensorflow
这类似于 virtualenv,我发现这很有用。