Python Tensorflow 是否与 Windows 工作流程兼容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33616094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is Tensorflow compatible with a Windows workflow?
提问by Tom Osterbind
I haven't seen anything about Windows compatibility -- is this on the way or currently available somewhere if I put forth some effort? (I have a Mac and an Ubuntu box but the Windows machine is the one with the discrete graphics card that I currently use with theano).
我还没有看到任何关于 Windows 兼容性的信息——如果我付出一些努力,它是在路上还是目前在某个地方可用?(我有一台 Mac 和一个 Ubuntu 机器,但 Windows 机器是我目前与 theano 一起使用的带有独立显卡的机器)。
采纳答案by mrry
Updated 11/28/2016:Today we released the first release candidate of TensorFlow 0.12, which includes support for Windows. You can install the Python bindings using the following command in a Python shell:
2016 年 11 月 28 日更新:今天我们发布了 TensorFlow 0.12 的第一个候选版本,其中包括对 Windows 的支持。您可以在 Python shell 中使用以下命令安装 Python 绑定:
C:\> pip install tensorflow
...or, if you want GPU support:
...或者,如果您需要 GPU 支持:
C:\> pip install tensorflow-gpu
You can also build TensorFlow yourself using Microsoft Visual C++ and NVCC (for the CUDA parts). The easiest way to build on Windows is currently to use the CMake build, and we will soon provide support for Bazel on Windows.
您还可以使用 Microsoft Visual C++ 和 NVCC(用于 CUDA 部分)自己构建 TensorFlow。目前在 Windows 上构建的最简单方法是使用CMake 构建,我们很快将在 Windows 上提供对Bazel 的支持。
Previous answer:We haven't tried to build TensorFlow on Windows so far: the only supported platforms are Linux (Ubuntu) and Mac OS X, and we've only built binaries for those platforms.
上一个答案:到目前为止,我们还没有尝试在 Windows 上构建 TensorFlow:唯一支持的平台是 Linux (Ubuntu) 和 Mac OS X,我们只为这些平台构建了二进制文件。
For now, on Windows, the easiest way to get started with TensorFlow would be to use Docker: http://tensorflow.org/get_started/os_setup.md#docker-based_installation
目前,在 Windows 上,开始使用 TensorFlow 的最简单方法是使用 Docker:http: //tensorflow.org/get_started/os_setup.md#docker-based_installation
It should become easier to add Windows support when Bazel (the build system we are using) adds support for building on Windows, which is on the roadmap for Bazel 0.3. You can see the full Bazel roadmap here.
当 Bazel(我们正在使用的构建系统)添加对在 Windows 上构建的支持时,添加 Windows 支持应该会变得更容易,这在 Bazel 0.3 的路线图上。您可以在此处查看完整的 Bazel 路线图。
In the meantime, you can follow issue 17 on the TensorFlow GitHub page.
同时,您可以关注TensorFlow GitHub 页面上的第 17 期。
回答by LudiMagister
Another way to run it on Windows is to install for example Vmware (a free version if you are not using it commercially), install Ubuntu Linux into that and then install TensorFlow using the Linux instructions. That is what I have been doing, it works well.
在 Windows 上运行它的另一种方法是安装例如 Vmware(如果您不使用它,则为免费版本),将 Ubuntu Linux 安装到其中,然后使用 Linux 说明安装 TensorFlow。这就是我一直在做的,效果很好。
回答by jaycode
As @mrry suggested, it is easier to set up TensorFlow with Docker. Here's how I managed to set it up as well as getting iPython Notebook up and running in my Docker environment (I find it really convenient to use iPython Notebook for all testing purposes as well as documenting my experiments).
正如@mrry 建议的那样,使用 Docker 设置 TensorFlow 更容易。下面是我设法设置它以及在我的 Docker 环境中启动和运行 iPython Notebook 的方法(我发现将 iPython Notebook 用于所有测试目的以及记录我的实验非常方便)。
I assume that you have installed both docker and boot2docker for Windows here.
我假设您已经在此处为 Windows 安装了 docker 和 boot2docker。
First, run TensorFlow docker on daemon and set it up so Jupyter server (iPython Notebook) can be accessed from your main Windows system's browser:
首先,在守护进程上运行 TensorFlow docker 并进行设置,以便可以从主 Windows 系统的浏览器访问 Jupyter 服务器(iPython Notebook):
docker run -dit -v /c/Users/User/:/media/disk -p 8888:8888 b.gcr.io/tensorflow/tensorflow:latest
Replace /c/Users/User/
with a path in your host you wish to mount i.e. where you can keep your iPython files. I don't know how to set it to other drives than C:, let me know if you do. /media/disk
is the location in your TensorFlow docker where your host path's mounted against.
替换/c/Users/User/
为您希望挂载的主机中的路径,即您可以保存 iPython 文件的位置。我不知道如何将它设置为 C: 以外的其他驱动器,如果你这样做了,请告诉我。/media/disk
是您的 TensorFlow docker 中安装主机路径的位置。
-p 8888:8888
basically means "map port 8888 in docker to 8888 in host directory". You can change the second part to other ports if you wish.
-p 8888:8888
基本上意味着“将 docker 中的端口 8888 映射到主机目录中的 8888”。如果您愿意,您可以将第二部分更改为其他端口。
When you got it running, you can access it by running the following code:
运行后,您可以通过运行以下代码来访问它:
docker exec -ti [docker-id] bash
Where [docker-id] can be found by running:
可以通过运行以下命令找到 [docker-id]:
docker ps
To start your ipython notebook server from within TensorFlow's docker, run the following command:
要从 TensorFlow 的 docker 中启动您的 ipython notebook 服务器,请运行以下命令:
ipython notebook --ip='*'
To allow ipython server to listen to all ip so your app may be accessible from host machine.
允许 ipython 服务器侦听所有 ip,以便您的应用程序可以从主机访问。
Instead of viewing your app in http://localhost:8888
, you can only view it in http://[boot2docker-ip]:8888
. To find boot2docker-ip
run this in your terminal (not boot2docker terminal):
http://localhost:8888
您不能在 中查看您的应用,而只能在 中查看http://[boot2docker-ip]:8888
。要boot2docker-ip
在您的终端(不是 boot2docker 终端)中找到运行它:
boot2docker ip
回答by Sung Kim
TensorFlow is not supporting Windows at this point, but Windows has changed. Windows 10 Build 14432 includes bash.
TensorFlow 在这一点上不支持 Windows,但 Windows 已经改变。Windows 10 Build 14432 包括 bash。
You can download the build from https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced
您可以从https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced下载构建
After installation, just install/enable bash, and type bash
in cmd. That's it.
安装后,只需安装/启用 bash,然后输入bash
cmd。就是这样。
(The image is from https://blogs.windows.com/windowsexperience/2016/04/06/announcing-windows-10-insider-preview-build-14316/)
(图片来自https://blogs.windows.com/windowsexperience/2016/04/06/annoucing-windows-10-insider-preview-build-14316/)
Then, run this (Python is already installed):
然后,运行这个(Python 已经安装):
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
Happy tensorflowing in Windows!
在 Windows 中愉快地张量流!
回答by Franck Dernoncourt
Initial support for building TensorFlow on Microsoft Windows was added on 2016-10-05 in commit d0d975f8c3330b5402263b2356b038bc8af919a2:
在2016 年 10月 5 日在提交d0d975f8c3330b5402263b2356b038bc8af919a2 中添加了对在 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
.
此 PR 包含对使用 CMake 在 Windows 上构建 TensorFlow(仅限 CPU)的初始版本支持。它包括在 Windows 上使用 CMake 构建的文档、用于在 Windows 上实现核心功能的特定于平台的代码,以及用于构建 C++ 示例培训程序和 PIP 包(仅限 Python 3.5)的 CMake 规则。CMake 规则支持使用 Visual Studio 2015 构建 TensorFlow。
Windows 支持正在进行中,我们欢迎您的反馈和贡献。
有关当前支持的功能的完整详细信息以及如何在 Windows 上构建 TensorFlow 的说明,请参阅文件
tensorflow/contrib/cmake/README.md
.
回答by George Liu
TensorFlow is now officially available on Windows!
TensorFlow 现已正式在 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.
TensorFlow 现在在 Microsoft Windows 上构建和运行(在 Windows 10、Windows 7 和 Windows Server 2016 上测试)。支持的语言包括 Python(通过 pip 包)和 C++。GPU 加速支持 CUDA 8.0 和 cuDNN 5.1。已知限制包括: 当前无法加载自定义操作库。当前不支持 GCS 和 HDFS 文件系统。以下OPS目前不能实现:DepthwiseConv2dNative,DepthwiseConv2dNativeBackpropFilter,DepthwiseConv2dNativeBackpropInput,反量化,Digamma,ERF,ERFC,Igamma,Igammac,lgamma函数,Polygamma,QuantizeAndDequantize,QuantizedAvgPool,QuantizedBatchNomWithGlobalNormalization,QuantizedBiasAdd,QuantizedConcat,QuantizedConv2D,QuantizedMatmul,QuantizedMaxPool,QuantizeDownAndShrinkRange,QuantizedRelu,量化Relu6,
回答by Tensorflow Support
2.0 Compatible Answer: (Added on 28th Jan, 2020) To install Tensorflow 2.x (2.0 or 2.1) from Source using Bazel in Windows PC, you can run the below code:
2.0 兼容答案:(于 2020 年 1 月 28 日添加)要在 Windows PC 中使用 Bazel 从 Source 安装 Tensorflow 2.x(2.0 或 2.1),您可以运行以下代码:
bazel build //tensorflow/tools/pip_package:build_pip_package
To make the TensorFlow package builder with CPU-only support:
要使 TensorFlow 包构建器仅支持 CPU:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
To make the TensorFlow package builder with GPU support:
要使 TensorFlow 包构建器具有 GPU 支持:
bazel build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package
For more information on Installing Tensorflow in Windows, refer this Tensorflow Installation Page.
有关在 Windows 中安装 Tensorflow 的更多信息,请参阅此Tensorflow 安装页面。
Compatibility Information of Tensorflow Versions
, Python Versions
and Build Tools
(Bazel, CMake), can be found in this link.
的兼容性信息Tensorflow Versions
,Python Versions
以及Build Tools
(巴泽尔,CMake的),可以发现这个链接。