為什麼在windows下用不了tensorflow?

使用winPython可以裝tensorflow嗎?
我是剛剛接觸深度學習,目前的理解就是tensorflow是一個庫,有Python和C++介面,那為什麼不能再windows上用啊。。。


11月29日,Google Brain 工程師團隊剛剛宣布在 TensorFlow 0.12 中加入初步的 Windows 原生支持。

谷歌在開發者博客上寫到:「原生的 Windows 版 TensorFlow 是自開源以來,我們工作的重中之重。儘管 Windows 的用戶們已經可以在 Docker 容器中運行 TensorFlow 了,我們仍然希望提供更加完整的原生體驗,包括對於 GPU 的支持。」


隨著 TensorFlow r0.12 版的發布,這一開源軟體庫現已支持 Windows7、10 和 Server 2016。同時,這一新版本可以讓用戶在 TensorFlow 訓練中得到 CUDA 8 的 GPU 加速。我們已將新版本在 PyPI 中封裝成型。現在你可以使用命令 C:&> pip install tensorflow 安裝 TensorFlow 了。

GPU 支持的命令:C:&> pip install tensorflow-gpu


有關 TensorFlow Windows 支持的更多細節請閱讀 r0.12 的版本注釋。


pypi 地址:

tensorflow 0.12.0rc0

TensorFlow Release 0.12.0 地址:

tensorflow/tensorflow


主要特性和提升:

  • TensorFlow 現在可以在 Microsoft Windows 中開發和運行了(已知在 Windows 10、Windows 7、Windows Server 2016 中運行良好)。支持的語言包括 Python(通過 pip package)和 C++。支持 CUDA 8.0 和 cuDNN5.1 GPU 加速。目前已知的限制有:現在無法載入自定義指令庫(custom op library)。不支持 CGS 和 HDFS 文件系統。
    下列指令無法實現: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, 和 Requantize。
  • Go:Go 中的實驗 API 可以創建和執行圖表(https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go)
  • 新的 checkpoint 格式現在是 tf.train.Saver 中的默認值。舊 V1 chekpoint 仍然可讀; 由 write_version 參數控制,tf.train.Saver 現在默認寫入新的 V2 格式。這種方式顯著降低了恢復期間所需的內存峰值,同時降低了延遲。
  • 為無矩陣(迭代)解算器增加了新的庫,支持 tensorflow/contrib/solvers 中的線性方程、線性最小二乘法,特徵值和奇異值。最初的版本具有 lanczos 雙對角化(bidiagonalization)、共軛梯度和 CGLS。
  • 為 matrix_solve_ls 和 self_adjoint_eig 增加了梯度。
  • 對原有內容進行了大量清理,為具有 C ++梯度的運算添加二階梯度,並改進現有梯度,使大多數運算現在可以多次微分。
  • 增加了常微分方程的求解器:tf.contrib.integrate.odeint。
  • 用於具有命名軸的張量的新 contrib 模塊,tf.contrib.labeled_tensor。
  • TensorBoard 中嵌入(embedding)的可視化。

主要 API 改進

  • BusAdjacency 枚舉被協議緩衝 DeviceLocality 代替。匯流排索引現在從 1 而不是 0 開始,同時,使用 bus_id==0,之前為 BUS_ANY。
  • Env::FileExists 和 FileSystem::FileExists 現在返回 tensorflow::Status 而不是一個 bool。任何此函數的調用者都可以通過向調用添加.ok()將返迴轉換為 bool。
  • C API:TF_SessionWithGraph 類型更名為 TF_Session,其在 TensorFlow 的綁定語言中成為首選。原來的 TF_Session 已更名為 TF_DeprecatedSession。
  • C API: TF_Port 被更名為 TF_Output。
  • C API: 調用者保留提供給 TF_Run、 TF_SessionRun、TF_SetAttrTensor 等的 TF_Tensor 對象的所有權。
  • 將 tf.image.per_image_whitening() 更名為 tf.image.per_image_standardization()。
  • 將 Summary protobuf 構造函數移動到了 tf.summary 子模塊。
  • 不再使用 histogram_summary、audio_summary、 scalar_summary,image_summary、merge_summary 和 merge_all_summaries。
  • 組合 batch_ *和常規版本的線性代數和 FFT 運算。常規運算現在也處理批處理。所有 batch_ * Python 介面已刪除。
  • tf.all_variables,tf.VARIABLES 和 tf.initialize_all_variables 更名為 tf.global_variables,tf.GLOBAL_VARIABLES 和 tf.global_variable_initializers respectively。

Bug 修復和其他的變化

  • 使用線程安全版本的 lgamma 函數。
  • 修復 tf.sqrt 負參數。
  • 修正了導致用於多線程基準的線程數不正確的錯誤。
  • 多核 CPU 上 batch_matmul 的性能優化。
  • 改進 trace,matrix_set_diag,matrix_diag_part 和它們的梯度,適用於矩形矩陣。
  • 支持復值矩陣的 SVD。

選自 Google Developers Blog:https://developers.googleblog.com/2016/11/tensorflow-0-12-adds-support-for-windows.html


Update 2016-10-29:
https://developers.googleblog.com/2016/11/tensorflow-0-12-adds-support-for-windows.html

Posted by Derek Murray, Software Engineer
Today we are launching preliminary Windows support for TensorFlow.

Native support for TensorFlow on Windows was one of the first requests we receivedafter open-sourcing TensorFlow. Although some Windows users have managed to run TensorFlow in a Docker container, we wanted to provide a more complete experience including GPU support.

With the release of TensorFlow r0.12, we now provide a native TensorFlow package for Windows 7, 10, and Server 2016. This release enables you to speed up your TensorFlow training with any GPU that runs CUDA 8.

We have published the latest release as a pip package in PyPI, so now you can install TensorFlow with a single command:

C:&> pip install tensorflow

And for GPU support:

C:&> pip install tensorflow-gpu

More details about Windows support and all of the other new features in r0.12 are included in the release notes.

We"re excited to offer more people the opportunity to use TF at maximum speed. Follow us on Twitter to be the first to hear about future releases – we"re @tensorflow.

Acknowledgements

Many people have contributed to making this release possible. In particular, we"d like to thank Guenther Schmuelling and Vit Stepanovs from Microsoft for their significant contributions to Windows support.

原答案:

TensorFlow之前沒有native Windows版本的原因主要有兩個:

  • TF自己的C++代碼不能用Visual Studio的MSVC toolchain編譯
  • TF在Linux和Mac上使用的Build System - Bazel不支持Windows

不過目前TF已經成功把代碼port到Windows,Bazel從0.3.2版本也開始支持Windows(雖然不太穩定,但基本能用。。)

現在有兩種在Windows上build TensorFlow的方法,
CMake: tensorflow/README.md at master · tensorflow/tensorflow · GitHub
Bazel: Windows Support and Documentation · Issue #17 · tensorflow/tensorflow · GitHub

TF在port C++代碼到Windows的時候用的是CMake, 所以這個方法除了編譯慢應該沒有大問題,並且已經開始支持GPU(GPU支持是很多人想在Windows上用TF的原因)。

Bazel build的優點是速度快,特別是incremental build會比CMake快很多,0.3.2版本還只能build TF的C++ example trainer,不過剛剛發布的0.4.0版本已經支持build python PIP package了。 GPU build with Bazel還要再等等。。

TensorFlow的計劃當然是等Bazel在Windows上穩定後,把整個Windows build遷移到Bazel。

如果不想自己build,TF之後可能也會直接發布一個Windows版本的Python wheel file (PIP package),應該能直接在winPython里安裝使用,不過目前在Windows上只支持Python 3.5。

相關的鏈接:
Releases · bazelbuild/bazel · GitHub
https://bazel.build/blog/2016/10/07/bazel-windows.html
The wait for TensorFlow on Windows is almost over
https://www.quora.com/Why-did-Google-decide-to-use-Bazel-with-TensorFlow


送上第一手的安裝教程:知乎專欄-windows10安裝Tensorflow


在Windows上可以使用,官方文檔有寫。
詳細請看官方文檔。


可以用呀,看官方教程,好像要裝docker。不過如果你升級win10到最新版本的話,裝個bash on windows,這樣就有了個ubuntu子系統,然後就很容易了。


我自己試過在 Windows 10 上裝 Tensorflow,最後感覺還不如卸了 Windows, 裝上 Linux,然後裝Tensorflow,還有其他的庫,這樣更輕鬆。


目前最新1.0版本完美支持windows了,只需一鍵安裝。

安裝方法見下知乎專欄


日期:2017-04-05,在windows10下可以可以正常使用tensorflow

但是安裝過程中遇到一點問題,可以通過百度或QQ群逐步解決。我來說說我的安裝經歷把,因為自己算是工作上的需要我需要使用神經網路,所以來找怎麼實現神經網路的東西,因為我只會用python,所以最終選擇了tensorflow。我是windows10的系統,從個人和工作角度來說我不會換成linux或者裝雙系統,所以我只能是windows10 python tensorflow。

1、版本問題

2、包的正確安裝方式

我一直使用的是python3.5 32位,為什麼會是使用的32位,因為當初為了使用一個模塊,那個時候只能用32位的(使用python是2016年年初的時候。)因為沒有注意版本的問題,我一直出現一個,pip install tensorflow 它一直提示我找不到對應的版本。索性我就把原來的python35給直接卸載了。然後從網上說anaconda很好,所以我就下載了最新的ancodna,後來反覆了很久,我還是沒有能夠裝上。我仔細看了最新的ancodna是python3.6的,我的版本還是不對。我決定用大招。

在網上手動下載了python3.5 64位(在網上看帖子,說tensorflow支持3.5,普遍貼紙不知最新的,不是最新的)。然後然後成功裝上了,然後再去找符合的tensorflow包,早到了包。

我使用

pip install numpy
pip install scipy
pip install matplotlib

上面上個成功安裝,但是我繼續

pip install tensorflow

失敗了,我不停的嘗試,一直沒有成功,我只好求助百度了。得到了這個

python安裝包問題小結 - Moady - 博客園

按照他說的,我成功解決了問題。經過了一天的折騰我終於成功可以使用tensorflow,現在剩下來的就是學習了。

下載ancodna:Download Anaconda Now! | Continuum https://www.continuum.io/downloads

python包下載,可以在這查詢到基本上所有的包還有版本Python Extension Packages for Windows

tensorflow已經支持python36了。


現在用pip就可以 知乎專欄

  • 安裝python 3.5 64位 版本
  • 安裝CUDA Toolkit CUDA 8.0 Downloads
  • 向CUDA Toolkit 添加cuDNN庫 NVIDIA cuDNN
  • 使用pip安裝tensorflow/tensorflow-gpu

pip install tensorflow
pip install tensorflow-gpu

  • 安裝後驗證

import tensorflow as tf
hello = tf.constant("Hello, TensorFlow!")

作者:趙照照
鏈接:知乎專欄
來源:知乎
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。


看來還是有很多人不知道這個網址啊:Python Extension Packages for Windows。他裡面庫的更新速度比官方快多了,基本上3.6都有了,用windows的先去那找,找不到再pypi。。


最新版本可以支持windows了,不過只支持python3,之前在windows是只能藉助docker用,docker屏蔽了container的ip和埠,用tensorboard的話那酸爽。。。
不過現在可以支持windows+gpu,可以起飛了


我上個星期剛完成window10上的安裝,已經測試通過了,寫了一個還比較詳細的安裝的過程,希望可以幫助你成功安裝window10 + cuda8.0+tensorflow 安裝教程


為何windows 10可以安裝成功,但是windows 8不管是tensorflow還是cudnn都安裝不成功,,並且cudnn官網都沒有windows 8的文件


可以的,python 3直接安裝tensorflow


不是不能用...就是挺麻煩..而且起很多功能用不了,直接linux多簡單..


可以用啊 ,不過要先裝docker ,但是windows下裝docker需要hyper-v,而以windows10為例,hyper-v只能在企業版或教育版下有,個人版無法安裝hyper-v,因此也就跑不了。所以趕緊上手Linux吧。
ps. 建議用Tensorflow-gpu版,深度神經網路跑起來比cpu版快的不是一星半點


可以參考我的安裝教程Windows10_64+tensorflow0.12+cuda8+cudnnv5+Anaconda4.2.0安裝教程


今天試了一下,錯誤很多,還是忍忍吧!


之前應該也可以通過docker在windows上安裝tensorflow吧?目前最新的0.12rc版本已經可以直接支持windows。


已經可以用了


你只要稍作忍耐,依目前的速度,估計到明年就能全面無節操支持Windows...


推薦閱讀:

TAG:機器學習 | 深度學習(Deep Learning) | TensorFlow |