close

由於Tensorflow 在0.12版之後已經支援windows,整個的安裝方式就不需要像以前那樣,直接透過pip的方式就可以很簡單的安裝

.CPU version

    pip install tensorflow

    或

    pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

.GPU version

    pip install tensorflow-gpu #需要CUDA 8

    或

    pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Tensorflow 0.11版本之前,在windows的安裝方式

我的環境是win7 64bits的環境(似乎無法在32 bits的環境下安裝),並在bios中打開virtualization功能,安裝完Docker後,執行Docker Quickstart Terminal

 

接著執行 docker-machine ls

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376

  再新增一個名為"vodcker"的docker machine

$ docker-machine create vdocker -d virtualbox

 再次執行docker-machine ls,可以發覺多了一個docker machine

NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376
vdocker   -        virtualbox   Running   tcp://192.168.99.101:2376

接著打開cmd,並輸入

FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd vdocker') DO %i

會得到以下訊息

C:\Users\xxx>FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd vd
ocker') DO %i

C:\Users\xxx>SET DOCKER_TLS_VERIFY=1

C:\Users\xxx>SET DOCKER_HOST=tcp://192.168.99.101:2376

C:\Users\xxx>SET DOCKER_CERT_PATH=C:\Users\Lihuei.Wang\.docker\machine\m
achines\vdocker

C:\Users\xxx>SET DOCKER_MACHINE_NAME=vdocker

C:\Users\xxx>REM Run this command to configure your shell:

C:\Users\xxx>REM FOR /f "tokens=*" %i IN ('docker-machine env --s
hell cmd vdocker') DO %i

之後再輸入

docker run -it b.gcr.io/tensorflow/tensorflow

會發覺當下載安成時,系統會hang在這

C:\Users\xxx>docker run -it b.gcr.io/tensorflow/tensorflow
[I 06:02:22.396 NotebookApp] Writing notebook server cookie secret to /root/.loc
al/share/jupyter/runtime/notebook_cookie_secret
[W 06:02:22.433 NotebookApp] WARNING: The notebook server is listening on all IP
addresses and not using encryption. This is not recommended.
[W 06:02:22.433 NotebookApp] WARNING: The notebook server is listening on all IP
addresses and not using authentication. This is highly insecure and not recomme
nded.
[I 06:02:22.440 NotebookApp] Serving notebooks from local directory: /notebooks
[I 06:02:22.440 NotebookApp] 0 active kernels
[I 06:02:22.440 NotebookApp] The Jupyter Notebook is running at: http://[all ip
addresses on your system]:8888/
[I 06:02:22.441 NotebookApp] Use Control-C to stop this server and shut down all
kernels (twice to skip confirmation).
python
[I 06:04:08.613 NotebookApp] interrupted
Serving notebooks from local directory: /notebooks
0 active kernels
The Jupyter Notebook is running at: http://[all ip addresses on your system]:888
8/

 

解決的辦法是多加 -p 8888:8888參數

docker run -p 8888:8888 -it b.gcr.io/tensorflow/tensorflow

 

之後鍵入在browser中鍵入http://192.168.99.101:8888/,就可以開啟ipython notebook

3  

 

若想在terminal中直接運行python運行tensor flow,可輸入以下指令安裝伴隨著source code的版本

docker run -it b.gcr.io/tensorflow/tensorflow:latest-devel

 

C:\Users\xxx>docker run -it b.gcr.io/tensorflow/tensorflow:latest-devel
root@3ec66b8e5770:~# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 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

 

 

參考資料:

1. http://www.netinstructions.com/how-to-install-and-run-tensorflow-on-a-windows-pc/

2. http://stackoverflow.com/questions/35582875/unable-to-start-tensorflow-within-docker-on-windows

3. http://stackoverflow.com/questions/36226872/having-difficulty-accessing-the-jupyter-notebook-when-trying-to-run-tensorflow-t

4. https://github.com/tensorflow/tensorflow/issues/42

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 kiazo1 的頭像
    kiazo1

    隨手亂寫

    kiazo1 發表在 痞客邦 留言(0) 人氣()