WindowsでTensorFlowをセットアップ

スポンサーリンク

Windowsで、といってもTensorFlow自体LinuxとMacのディストリビューションしかないので仮想環境で動かすだけです。

VirtualBox, Vagrant, Gitをインストールする

VirtualBoxVagrant、GitからWindows用インストーラーをダウンロードして普通にインストール、再起動します。

GitのsshにはPathを通しておきます。

CoreOSをVagrantで実行

Win+Rで「powershell」と入力しPowerShellを開きます。
私はMy Documents以下に「app\vagrant」を作成していますので、移動して作業します。

PS C:\Users\Tono\Documents\app\vagrant> vagrant box add https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/15.04/ubuntu-15.04-amd64.box
==> box: Box file was not detected as metadata. Adding it directly...
A name is required when adding a box file directly. Please pass
the `--name` parameter to `vagrant box add`. See
`vagrant box add -h` for more help.
PS C:\Users\Tono\Documents\app\vagrant> vagrant box add ubuntu-15 https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/15.04/ubuntu-15.04-amd64.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu-15' (v0) for provider:
    box: Downloading: https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/15.04/ubuntu-15.04-amd64.box
    box: Progress: 89% (Rate: 95185/s, Estimated time remaining: 0:05:12)    box: Progress: 89% (Rate: 97463/s, Estimated time     box: Progress: 100% (Rate: 175k/s, Estimated time remaining: --:--:--)imated time remaining: 0:05:11)
==> box: Successfully added box 'ubuntu-15' (v0) for 'virtualbox'!
PS C:\Users\Tono\Documents\app\vagrant> mkdir ubuntu
 
 
    ディレクトリ: C:\Users\Tono\Documents\app\vagrant
 
 
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2016/03/31     22:14                ubuntu
 
 
PS C:\Users\Tono\Documents\app\vagrant> cd .\ubuntu\
PS C:\Users\Tono\Documents\app\vagrant\ubuntu> vagrant init ubuntu-15
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
PS C:\Users\Tono\Documents\app\vagrant\ubuntu> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu-15'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: ubuntu_default_1459430102198_35265
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.22_Ubuntu r98236
    default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Tono/Documents/app/vagrant/ubuntu
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
 
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
 
The error output from the last command was:
 
stdin: is not a tty
mount: unknown filesystem type 'vboxsf'
PS C:\Users\Tono\Documents\app\vagrant\ubuntu> vagrant ssh
Welcome to Ubuntu 15.04 (GNU/Linux 3.19.0-15-generic x86_64)
 
 * Documentation:  https://help.ubuntu.com/
Your Ubuntu release is not supported anymore.
For upgrade information, please visit:
http://www.ubuntu.com/releaseendoflife
 
New release '15.10' available.
Run 'do-release-upgrade' to upgrade to it.

ここまででUbuntuが立ち上がります。

virtualenv環境を準備する

Python関係をインストールします。

vagrant@vagrant-ubuntu-trusty:~$ 

TensorFlowのインストール

vagrant@vagrant-ubuntu-trusty:~$ virtualenv --system-site-packages ~/tensorflow
vagrant@vagrant-ubuntu-trusty:~$ source ~/tensorflow/bin/activate
(tensorflow)vagrant@vagrant-ubuntu-trusty:~$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
(以降TensorFlowの長いログ)

テストの実行

(tensorflow)vagrant@vagrant-ubuntu-trusty:~$ python
Python 2.7.9 (default, Apr  2 2015, 15:33:21)
[GCC 4.9.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!

普通に動きました。

スポンサーリンク







シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク