C++ 如何在 Windows 上安装 TensorFlow?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34785414/
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
How to install TensorFlow on Windows?
提问by ProEns08
I am starting to work with TensorFlow library for deep learning, https://www.tensorflow.org/.
我开始使用 TensorFlow 库进行深度学习,https://www.tensorflow.org/ 。
I found a explicit guide to work on it on linux and Mac but I did not find how to work with it under Windows. I try over the net, but the information are lacking.
我找到了在 linux 和 Mac 上使用它的明确指南,但我没有找到如何在 Windows 下使用它。我尝试通过网络,但缺乏信息。
I use Visual Studio 2015 for my projects, and I am trying to compile the library with Visual studio Compiler VC14.
我将 Visual Studio 2015 用于我的项目,并且我正在尝试使用 Visual Studio Compiler VC14 编译库。
How to install it and to use it under Windows?
如何在 Windows 下安装和使用它?
Can I use Bazel for Windows for production use?
我可以将Bazel for Windows用于生产用途吗?
回答by Guy Coder
How to install TensorFlow and to use it under Windows?
如何安装 TensorFlow 并在 Windows 下使用它?
Updated on 8/4/16
16 年 8 月 4 日更新
Windows 10 now has a UbuntuBash environment, AKA Bash on Ubuntu on Windows, available as a standard option (as opposed to Insider Preview updates for developers). (StackOverflow tag wsl) This option came with the Windows 10 anniversary update(Version 1607) released on 8/2/2016. This allows the use of apt-getto install software packages such as Pythonand TensorFlow.
Windows 10 现在有一个UbuntuBash 环境,AKA Bash on Ubuntu on Windows,作为标准选项提供(与面向开发人员的 Insider Preview 更新相反)。(StackOverflow 标签wsl)此选项随2016 年 8 月 2 日发布的Windows 10 周年更新(版本 1607)一起提供。这允许使用apt-get来安装Python和TensorFlow等软件包。
Note: Bash on Ubuntu on Windows does not have access to the GPU, so all of the GPU options for installing TensorFlow will not work.
注意:Windows 上的 Ubuntu 上的 Bash 无法访问 GPU,因此用于安装 TensorFlow 的所有 GPU 选项都不起作用。
The dated installation instructionsfor Bash on Ubuntu on Windows are basically correct, but only these steps are necessary:
Prerequisites
Enable the Windows Subsystem for Linux feature (GUI)
Reboot when prompted
Run Bash on Windows
在 Windows 上的 Ubuntu 上 Bash的过时安装说明基本上是正确的,但只有这些步骤是必要的:
先决条件
启用 Windows 子系统 Linux 功能 (GUI)
出现提示时重新启动
在 Windows 上运行 Bash
Steps no longer needed:
Turn on Developer Mode
Enable the Windows Subsystem for Linux feature (command-line)
不再需要的步骤:
打开开发人员模式
启用适用于 Linux 的 Windows 子系统功能(命令行)
Then install TensorFlow using apt-get
然后使用 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
and now test TensorFlow
现在测试 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()
and run an actual neural network
并运行一个实际的神经网络
python3 -m tensorflow.models.image.mnist.convolutional
Earlier Answer
较早的回答
After learning about the developer preview of Bash on Windows.
在了解了 Windows 上的 Bash 开发者预览版之后。
See Playing with TensorFlow on Windowsby Scott Hanselman which uses Bash on Windows 10
请参阅在 Windows 10 上使用Bash的 Scott Hanselman在 Windows 上使用 TensorFlow
Original Answer
原答案
Bazel is the problem
巴泽尔是问题
TensorFlow is not made with build automation toolssuch as make, but with Google's in-house build tool Bazel. Bazel only works on systems based on Unixsuch as Linuxand OS X.
TensorFlow 不是使用make等构建自动化工具制作的,而是使用 Google 的内部构建工具Bazel 制作的。Bazel 仅适用于基于Unix 的系统,例如Linux和OS X。
Since the current published/known means to build TensorFlow uses Bazeland Bazel does not work on Windows, one can not install or run TensorFlow natively on Windows.
由于当前发布/已知的构建 TensorFlow 的方法使用Bazel,而 Bazel 在 Windows 上不起作用,因此无法在 Windows 上本地安装或运行 TensorFlow。
From 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.
窗户呢?
由于其 UNIX 传统,将 Bazel 移植到 Windows 是一项重要的工作。例如,Bazel 广泛使用符号链接,它在 Windows 版本之间具有不同级别的支持。
我们目前正在积极致力于改进 Windows 支持,但距离可用还有很长的路要走。
Status
地位
See: TensorFlow issue #17
See: Bazel issue #276
参见:TensorFlow 问题 #17
参见:Bazel 问题 #276
Solutions
解决方案
The solutions are listed in the order of complexity and work needed; from about an hour to may not even work.
解决方案按照复杂性和所需工作的顺序列出;从大约一个小时到甚至可能都不起作用。
- Docker
~ 1 hour
- 码头工人
~ 1 小时
Docker is a system to build self contained versions of a Linux operating system running on your machine. When you install and run TensorFlow via Docker it completely isolates the installation from pre-existing packages on your machine.
Docker 是一个系统,用于构建在您的机器上运行的 Linux 操作系统的自包含版本。当您通过 Docker 安装和运行 TensorFlow 时,它会将安装与您机器上预先存在的软件包完全隔离。
Also look at TensorFlow - which Docker image to use?
还要看看TensorFlow - 要使用哪个 Docker 镜像?
- OS X
~ 1 hour
- OS X
~ 1 小时
If you have a current Mac running OS X then see: Installation for Mac OS X
如果您当前使用的是运行 OS X 的 Mac,请参阅:Mac OS X 安装
- Linux
- Linux
The recommend Linux systemtends to be Ubuntu 14.04 LTS(Download page).
该建议Linux系统往往是Ubuntu的LTS 14.04(下载页面)。
a. Virtual Machine - Hardware Virtualization - Full Virtualization
~ 3 hours
一种。虚拟机 -硬件虚拟化 - 完全虚拟化
~ 3 小时
Download and install a virtual machine such as the commercial VMwareor the free Virtual Box, after which you can install Linux and then install TensorFlow.
下载并安装一个虚拟机,例如商业的VMware或免费的Virtual Box,之后您可以安装 Linux,然后安装 TensorFlow。
When you go to install TensorFlow you will be using Pip- Python's package management system. Visual Studio users should think NuGet. The packages are known as wheels.
当您去安装 TensorFlow 时,您将使用Pip——Python 的包管理系统。Visual Studio 用户应该考虑 NuGet。这些包被称为轮子。
See: Pip Installation
请参阅:Pip 安装
If you need to build from the source then see: Installing From Sources
~ 4 hours
Note: If you plan on using a Virtual Machine and have never done so before, consider using the Docker option instead, since Docker is the Virtual Machine, OS and TensorFlow all packaged together.
注意:如果您计划使用虚拟机并且以前从未这样做过,请考虑使用 Docker 选项,因为 Docker 是虚拟机、操作系统和 TensorFlow 都打包在一起。
b. Dual boot
~ 3 hours
湾 双启动
~ 3 小时
If you want to run TensorFlow on the same machine that you have Windows and make use of the GPU version then you will most likely have to use this option as running on a hosted Virtual Machine, Type 2 hypervisor, will not allow you access to the GPU.
如果您想在装有 Windows 的同一台机器上运行 TensorFlow 并使用 GPU 版本,那么您很可能必须使用此选项,因为在托管虚拟机上运行,类型 2 管理程序将不允许您访问图形处理器。
- Remote machine
~ 4 hours
- 远程机器
~4小时
If you have remote accessto another machine that you can install the Linux OS and TensorFlow software on and allow remote connections to, then you can use your Windows machine to present the remote machine as an application running on Windows.
如果您可以远程访问另一台可以安装 Linux 操作系统和 TensorFlow 软件并允许远程连接的机器,那么您可以使用您的 Windows 机器将远程机器呈现为在 Windows 上运行的应用程序。
- Cloud Service
I have no experience with this. Please edit answer if you know.
- 云服务
我没有这方面的经验。如果您知道,请编辑答案。
Cloudservices such as AWSare being used.
From TensorFlow Features
Want to run the model as a service in the cloud? Containerize with Docker and TensorFlow just works.
想要在云中将模型作为服务运行?使用 Docker 和 TensorFlow 进行容器化很有效。
From Docker
来自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.
在 AWS 上运行 Docker 提供了一种高度可靠、低成本的方式来快速构建、发布和运行大规模分布式应用程序。使用来自 AWS Marketplace 的 AMI 部署 Docker。
- Wait for Bazel to work on Windows.
- 等待 Bazel 在 Windows 上工作。
Currently it appears the only hold up is Bazel, however Bazel's roadmaplist working on Windows should be available this year.
目前看来唯一的阻碍是 Bazel,但是Bazel在 Windows 上工作的路线图列表应该会在今年推出。
There are two features listed for 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.
- Build TensorFlow by hand.
A few days or more depending on you skill level. I gave up on this one; too many subprojects to build and files to locate.
- 手动构建 TensorFlow。
几天或更长时间取决于您的技能水平。我放弃了这个;要构建的子项目和要定位的文件太多。
Remember that Bazel is only used to build TensorFlow. If you get the commands Bazel runs and the correct source code and libraries you should be able to build TensorFlow on Windows. See: How do I get the commands executed by Bazel.
请记住,Bazel 仅用于构建 TensorFlow。如果您获得 Bazel 运行的命令以及正确的源代码和库,您应该能够在 Windows 上构建 TensorFlow。请参阅:如何获取 Bazel 执行的命令。
While I have not researched this more, you can look at the continuous integrationinfo for needed files and info on how to they build it for testing. (Readme) (site)
虽然我没有对此进行更多研究,但您可以查看所需文件的持续集成信息以及有关如何构建它以进行测试的信息。(自述文件)(网站)
- Build Bazel on Windows
A few days or more depending on you skill level. I gave up on this one also; could not find the necessary source files needed for Windows.
- 在 Windows 上构建 Bazel
几天或更长时间,具体取决于您的技能水平。我也放弃了这个;找不到 Windows 所需的必要源文件。
There is a public experimental source code version of Bazel that boots on Windows. You may be able to leverage this into getting Bazel to work on Windows, etc.
有一个在 Windows 上启动的Bazel的公共实验源代码版本。您可以利用这一点让 Bazel 在 Windows 等上工作。
Also these solutions require the use of Cygwinor MinGWwhich adds another layer of complexity.
此外,这些解决方案需要使用Cygwin或MinGW,这增加了另一层复杂性。
- Use alternative build system such as Make
If you get this one to work I would like to see in on GitHub.
- 使用替代构建系统,例如 Make
如果你让这个系统工作,我希望在 GitHub 上看到。
This currently does not exist for TensorFlow. It is a feature request.
目前 TensorFlow 不存在此功能。这是一个功能请求。
See: TensorFlow issue 380
- Cross Build
If you get this one to work I would like to see in on GitHub.
- 交叉构建
如果你让这个工作起来,我希望在 GitHub 上看到。
You build TensorFlow on Linux using Bazel but change the build process to output a wheel that can be installed on Windows. This will require detailed knowledge of Bazel to change the configuration, and locating the source code and libraries that work with Windows. An option I would only suggest as a last resort. It may not even be possible.
您使用 Bazel 在 Linux 上构建 TensorFlow,但更改构建过程以输出可安装在 Windows 上的轮子。这将需要详细了解 Bazel 以更改配置,并找到适用于 Windows 的源代码和库。我只建议作为最后的手段的选项。它甚至可能是不可能的。
- Run on the new Windows Subsystem for Linux.
- 在适用于 Linux 的新 Windows 子系统上运行。
See: Windows Subsystem for Linux Overview
You will know as much as I do by reading the referenced article.
通过阅读参考文章,您会和我一样了解。
Can I use Bazel for Windows for production use?
我可以将 Bazel for Windows 用于生产用途吗?
Since it is experimental software I would not use on a production machine.
由于它是实验性软件,我不会在生产机器上使用。
Remember that you only need Bazel to build TensorFlow. So use the experimental code on a non production machine to build the wheel, then install the wheel on a production machine. See: Pip Installation
请记住,您只需要 Bazel 即可构建 TensorFlow。所以使用非生产机器上的实验代码来构建车轮,然后将车轮安装在生产机器上。请参阅:Pip 安装
TLDR;
TLDR;
Currently I have several versions for learning. Most use a VMWare 7.1 Workstation to host Ubuntu 14.04 LTS or Ubuntu 15 or Debian. I also have one dual boot of Ubuntu 14.04 LTS on my Windows machine to access the GPU as the machine with VMware does not have the proper GPU. I would recommend that you give these machines at least 8G of memory either as RAM or RAM and swap space as I have run out of memory a few times.
目前我有几个版本可供学习。大多数使用 VMWare 7.1 工作站来托管 Ubuntu 14.04 LTS 或 Ubuntu 15 或 Debian。我的 Windows 机器上还有一个双启动 Ubuntu 14.04 LTS 来访问 GPU,因为装有 VMware 的机器没有合适的 GPU。我建议你给这些机器至少 8G 的内存作为 RAM 或 RAM 和交换空间,因为我有几次内存不足。
回答by michaelosthege
I can confirm that it works in the Windows Subsystem for Linux! And it is also very straightforward.
我可以确认它适用于 Linux 的 Windows 子系统!而且它也非常简单。
In the Ubuntu Bash on Windows 10, first update the package index:
在 Windows 10 上的 Ubuntu Bash 中,首先更新包索引:
apt-get update
Then install pip for Python 2:
然后为 Python 2 安装 pip:
sudo apt-get install python-pip python-dev
Install tensorflow:
安装张量流:
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
The package is now installed an you can run the CNN sample on the MNIST set:
该包现已安装,您可以在 MNIST 集上运行 CNN 示例:
cd /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist
python convolutional.py
I just tested the CPU package for now.
我现在只是测试了 CPU 包。
I blogged about it: http://blog.mosthege.net/2016/05/11/running-tensorflow-with-native-linux-binaries-in-the-windows-subsystem-for-linux/
我写了关于它的博客:http: //blog.mosthege.net/2016/05/11/running-tensorflow-with-native-linux-binaries-in-the-windows-subsystem-for-linux/
cheers
干杯
~michael
~迈克尔
回答by Dudnikof
Sorry for the excavation, but this question is quite popular, and now it has a different answer.
抱歉挖掘,但是这个问题很受欢迎,现在有了不同的答案。
Google officially announced the addition of Windows (7, 10, and Server 2016) support for TensorFlow: developers.googleblog.com
Google 正式宣布为 TensorFlow 添加 Windows(7、10 和 Server 2016)支持: developers.googleblog.com
The Python module can be installed using pip with a single command:
可以使用带有单个命令的 pip 安装 Python 模块:
C:\> pip install tensorflow
And if you need GPU support:
如果您需要 GPU 支持:
C:\> pip install tensorflow-gpu
TensorFlow manual - How to install pip on windows
TensorFlow 手册 - 如何在 Windows 上安装 pip
Another useful information are included in release notes: https://github.com/tensorflow/tensorflow/releases
另一个有用的信息包含在发行说明中:https: //github.com/tensorflow/tensorflow/releases
UPD:As @m02ph3u5 right mentioned in the comments TF for windows supports only Python 3.5.x Installing TensorFlow on Windows with native pip
UPD:正如评论中提到的@m02ph3u5 TF for windows 仅支持 Python 3.5.x在 Windows 上使用本机 pip 安装 TensorFlow
回答by Franck Dernoncourt
Installing TensorFlow
安装 TensorFlow
TensorFlow currently supports only Python 3.5 64-bit. Both CPU and GPU are supported. Here are some installation instructions assuming you do not have Python 3.5 64-bit:
TensorFlow 目前仅支持 Python 3.5 64 位。支持 CPU 和 GPU。假设您没有 Python 3.5 64 位,以下是一些安装说明:
- Download and install Microsoft Visual C++ 2015 Redistributable Update 3: https://www.microsoft.com/en-us/download/details.aspx?id=53587(required by Python 3.5 and TensorFlow)
- Download and install Python 3.5 64-bit: https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
- Install pip as follows: download https://bootstrap.pypa.io/get-pip.py, then run
python get-pip.py
- Install TensorFlow with either
pip install tensorflow
(CPU version) orpip install tensorflow-gpu
(GPU version --> requires CUDA to be installed).
- 下载并安装 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 。
Testing TensorFlow
测试 TensorFlow
You can now run something like following to test whether TensorFlow is working fine:
您现在可以运行类似以下内容来测试 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 comes with a few models, which are located in C:\Python35\Lib\site-packages\tensorflow\models\
(assuming you installed python in C:\Python35
). For example, you can run in the console:
TensorFlow 附带了一些模型,它们位于C:\Python35\Lib\site-packages\tensorflow\models\
(假设您在 中安装了 python C:\Python35
)。例如,您可以在控制台中运行:
python -m tensorflow.models.image.mnist.convolutional
or
或者
python C:\Python35\Lib\site-packages\tensorflow\models\image\mnist\convolutional.py
Limitations of TensorFlow on Windows
TensorFlow 在 Windows 上的限制
Initial support for building TensorFlow on Microsoft Windows was added on 2016-10-05 in commit 2098b9abcf20d2c9694055bbfd6997bc00b73578:
在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
.
此 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
.
The Microsoft Windows support was introduced in TensorFlow in version 0.12 RC0 (release notes):
TensorFlow 0.12 RC0 版(发行说明)中引入了 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.
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, QuantizedRelu6、QuantizedReshape、QuantizeV2、
回答by Silverstorm
Now Tensorflow is officially supported in Windows, you can install it using pip
command of Python 3.5 without compile it yourself
现在 Windows 正式支持 Tensorflow,您可以使用pip
Python 3.5 的命令安装它,无需自己编译
CPU Version
CPU版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl
cp35indicates python 3.5wheel, 0.12.0the version, you can edit these according your preference, or to install latest CPU version available you can use
cp35表示python 3.5轮子,0.12.0版本,你可以根据自己的喜好编辑这些,或者安装最新的CPU版本你可以使用
pip install --upgrade tensorflow
GPU Version
GPU版本
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl
cp35indicates python 3.5wheel, 0.12.0the version, you can edit these according your preference, or to install latest GPU version available you can use
cp35表示python 3.5wheel,0.12.0版本,你可以根据自己的喜好编辑这些,或者安装最新的GPU版本你可以使用
pip install --upgrade tensorflow-gpu
回答by ivan.ukr
Following may work for you: install Virtual Box, create Linux VM and install Linux into it. I'd recommend Ubuntu, because Google often uses it internally. Then, install TensorFlow in Linux VM.
以下可能对您有用:安装 Virtual Box,创建 Linux VM 并将 Linux 安装到其中。我推荐 Ubuntu,因为 Google 经常在内部使用它。然后,在 Linux VM 中安装 TensorFlow。
回答by Dezo
As of writing this answer, I wasn't able to get tensorflow to install properly with python version 3.5.2. Reverting to python 3.5.0did the trick.
在撰写此答案时,我无法使用 python 3.5.2 版正确安装 tensorflow。恢复到python 3.5.0成功了。
Then I was able to install with
然后我就可以安装了
C:> pip install tensorflow
C:> pip 安装张量流
回答by dexhunter
If you have already installed anaconda on your windows, there is an easier way as I found out:
如果您已经在 Windows 上安装了 anaconda,那么我发现有一种更简单的方法:
conda create --name snakes python=3
Then
然后
activate snakes
Then
然后
pip install tensorflow
This is similar to virtualenv and I found this helpful.
这类似于 virtualenv,我发现这很有帮助。
回答by fabrizioM
You can't at the moment. The problem is that tensorflow uses the bazel build another Google internal tool that has been exposed as an open source projectand it has only support for mac and unix. Until bazel is ported to windows or another build system is added to tensorflow there is a little chance to run tensorflow natively on windows.
你现在不能。问题在于,tensorflow 使用 bazel 构建了另一个谷歌内部工具,该工具已作为开源项目公开,并且仅支持 mac 和 unix。在将 bazel 移植到 Windows 或将另一个构建系统添加到 tensorflow 之前,很少有机会在 Windows 上本地运行 tensorflow。
That said you can install virtualbox and then install docker-machine and run a linux container with tensorflow inside it.
也就是说,您可以安装 virtualbox,然后安装 docker-machine 并在其中运行带有 tensorflow 的 linux 容器。
回答by Fagui Curtain
I managed to install TensorFlow on Win8.1 without Docker using advice from https://discussions.udacity.com/t/windows-tensorflow-and-visual-studio-2015/45636
我设法使用来自https://discussions.udacity.com/t/windows-tensorflow-and-visual-studio-2015/45636 的建议在没有 Docker 的情况下在 Win8.1 上安装 TensorFlow
I tried a lot of stuff before that, and i won't try to install it twice but here is what i did: - install VS2015 (make sure Visual C++ installed as well) - install Python Tools for VS2015 - install Python2.7 with Anaconda2 - install pip and conda for Python - install numpy with pip inside VS2015 - install tensorflow with pip inside VS2015
在此之前我尝试了很多东西,我不会尝试安装它两次,但这是我所做的: - 安装 VS2015(确保安装了 Visual C++) - 安装 Python Tools for VS2015 - 安装 Python2.7 Anaconda2 - 为 Python 安装 pip 和 conda - 在 VS2015 中使用 pip 安装 numpy - 在 VS2015 中使用 pip 安装 tensorflow
i didn't manage to do it with Python3.5
我没有设法用 Python3.5 做到这一点
I managed also to install on Win8.1 via Cloud9 There is a video tutorial on Youtube.
我还设法通过 Cloud9 在 Win8.1 上安装 Youtube 上有一个视频教程。
https://www.youtube.com/watch?v=kMtrOIPLpR0
https://www.youtube.com/watch?v=kMtrOIPLpR0
EDIT: actually for the above, (not Cloud9 which is fine) i have problems:
TensorFlow LOOKS LIKE it's installed (i can see it in the list of modules installed in VS2015 when clicking in Solution Explorer on Python 64-bit 2.7)
butif i type in a script or in Python Interactive import tensorflow as TF
then i get an error message
编辑:实际上对于上述内容(不是 Cloud9,这很好)我有问题:TensorFlow 看起来像它已安装(当单击 Python 64 位 2.7 上的解决方案资源管理器时,我可以在 VS2015 中安装的模块列表中看到它)
但是如果我输入脚本或 Python Interactiveimport 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