TensorFlowăŻăćŠć˘°ĺŚçżç¨ăŽă˘ăŤă´ăŞăşă ăč¨čż°ăăăăăŽă¤ăłăżăźăă§ăźăšă§ă大čŚć¨Ąăˇăšăă ăăăšăăăžă§ăĺš ĺşăç°ĺ˘ă§ä˝żăăăŽăĺŠçšăŽăăă§ăă
Qiitaă§ăăăŞă芹éĄăŤăŞăŁăŚăăăçžćçšă§ăă§ăŤ100䝼ä¸ăŽć稿ăăăăžăăăăŽăăăăăçšăŤć¸ăăă¨ăŻăŞăăŽăăŞăźă¨ćăŁăŚăžăăăăMac + DockerăŽç°ĺ˘ă§ă¤ăłăšăăźăŤăăäžăčŚĺ˝ăăăŞăăŁăăŽă§ăăăĄăăŽăĄă˘ăć¸ăăŚăăăă¨ăŤăăžăăăTensorFlowăŽĺşćŹçăŞč§ŁčŞŹăçĽăăăćšăŻăăăĄăăŽč¨äşă垥茧ăă ăăă
äťăžă§ä˝żăŁăăă¨ăăŞăăŁăăŽă§é˘ç˝ăăăă¨ăăăŽă丝ăŞççąă§ăăăMacă§TensorFlowă使ăĺ ´ĺăŻăDockeră§ă¤ăłăšăăźăŤăăăŽăç°Ąĺă ăăă¨ăăĄăăŽč¨äşăŤć¸ăăŚăăŁăăăăăăăžăăWindowsăŽĺ ´ĺăăDockeră使ăăŽăä¸çŞćĽ˝ăă¨ăăĄăăŽćšă§č¨ăăăŚăžăă
Dockerç°ĺ˘ăŽćşĺ
ăžăăăăĄăăăDocker ToolboxăăăŚăłăăźăăăŚăă¤ăłăšăăźăŤăăžăăăăăăăŤăăăVirtualBoxďźäťŽćłĺă˝ăăďźăDockerăŻăŠă¤ă˘ăłăăăŞăŠăä¸ćŹă¤ăłăšăăźăŤăăăžăă
ă¤ăłăšăăźăŤăŽéä¸ă§"Choose a tool to get started with Docker"ă¨ăăăăăłăăăĺşăŚăDocker Quickstart TerminalăKitematicăé¸ăśăă¨ăă§ăăžăăăăăăŻDocker Quickstart Terminalăé¸ăłăžăăăă
ăăă¨ăăżăźăăăŤă辡ĺăădefaultă¨č¨ăăăDocker machineďźDockerç¨ăŽäťŽćłăăˇăłďźăŽčľˇĺăŞăŠăčĄăăăćçľçăŤDockerăčľ°ăĺşăăžăă
ăĄăŞăżăŤăăăŽDocker Quickstart TerminalăŻă˘ăăŞăąăźăˇă§ăł/DockerăăŠăŤăĺ ăŤäżĺăăăŚăăžăă
Dockerăăăžăă¤ăłăšăăźăŤăăăăă確čŞăăăăădocker run hello-world
ă¨ćăŁăŚăżăžăăăăăăă¨ă
Hello from Docker.
This message shows (䝼ä¸çĽ)
ăĺŤăä¸éŁăŽăĄăăťăźă¸ăĺşăăŻăă§ăă
ăăă§ăĺä˝ç˘şčŞă§ăăžăăă
TensorFlowăŽDocker containeră辡ĺăăă
Dockeră§ăŻăOSă¨ă˘ăăŞăąăźăˇă§ăłăăăăąăźă¸ĺăăăimageăădockerfileăăăăŤăă¨ăăŚăŹăă¸ăăŞăŤçťé˛ăăăŚăźăśăźăŽç°ĺ˘ä¸ăŽDockerăŻăŠă¤ă˘ăłăă§ăăŽă¤ăĄăźă¸ăĺŽčĄăăăă¨ă§ăă˘ăăŞăąăźăˇă§ăłăĺŤăcontainerăä˝ćăăžăă
ĺ ŹĺźăŤăăéăăTensorflowăŽcontainerăŻäťĽä¸ăŽăłăăłăă§ä˝ćăăžăă
$ docker run -it b.gcr.io/tensorflow/tensorflow
ăăă§ădocker run
ăŻăłăłăăăä˝ćăăăłăăłăăăŞăăˇă§ăł -it
ăŻăłăłăăĺ
ăŤăˇă§ăŤă辡ĺăăăŚăłăăłăćä˝ăăăăŽăŤä˝żăăžăăb.gcr.io/tensorflow/tensorflow
ăŻDockeră¤ăĄăźă¸ăŽĺ ´ćă§ăăMacăWindowsç°ĺ˘ă§ăŻăGPUăľăăźăăŻçĄăăŽă§ćŞăăăăă
ăłăăłăăĺŽčĄăăăă¨ăăľăźăăźăăă¤ăĄăźă¸ăăăŚăłăăźăăăŚăăˇă§ăŤăŽăăăłăăăĺşăŚăăžăă
ăăă§ă~# python
ăŽĺ˝˘ă§ăpythonăżăźăăăŤă辡ĺă§ăăžăăă¨ăăăăăĺ ŹĺźăŤăăăľăłăăŤăĺ ĽĺăăŚăżăžăăăă
>>> 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()
ăăżă¤ăăăŚăpythonăżăźăăăŤăçľäşă§ăăžăăDocker containerăŽăˇă§ăŤčŞä˝ăŻăexită§çľäşă§ăăžăă
ăă˘ă˘ăăŤăĺŽčĄăă
ăăĄăăŽĺ
ŹĺźăăĽăźăăŞă˘ăŤăŤăăćć¸ăćĺčŞčăŽăă˘ă˘ăăŤăĺŽčĄăăžăăçľć§ăĄă˘ăŞăĺż
čŚă¨ăăăŽă§ăăăăăădocker machineăŽăĄă˘ăŞăĺ˘ăăăžăăăăăăăăăŽćçšă§ăŻDocker Quickstartă辡ĺăădefaultăăˇăźăłă辡ĺăăŚăăăŻăă§ăăăżăźăăăŤă§ docker-machine ls
ăĺŽčĄăăçžĺ¨čľ°ăŁăŚăăDocker machineă確čŞăăžăăăă
ăžăădefaultăăˇăźăłăŽçžĺ¨ăŽăĄă˘ăŞĺŽšéăŻdocker-machine inspect default
ă§ç˘şčŞă§ăăžă("Driver"ăŽ"Memory"ăŽé¨ĺďźă
CPUăŻďźă¤ăMemoryăŻ2048(KB)ăŽăăă§ăă
ăăă§ădocker-machine rm default
ă§defaultăăˇăźăłăĺć˘ăădocker-machine create --driver virtualbox --virtualbox-memory 4096 --virtualbox-cpu-count 4 default
ă§4CPU, 4096KBăĄă˘ăŞăŽdefaultăăˇăźăłăćšăăŚčľˇĺăăžăăăďźĺč1, ĺč2ďźă辡ĺăăăădocker-machine inspect default
ă§ăč¨ĺŽăĺć ăăăŚăăă確čŞăăŚăă ăăă
確čŞă§ăăăă
docker run -it b.gcr.io/tensorflow/tensorflow
ăă§TensorFlowăłăłăăăä˝ćăăŚă
python -m tensorflow.models.image.mnist.convolutional
ă§ăă˘ă˘ăăŤăĺŽčĄăăŚăă ăăăăĄăŞăżăŤă-măŞăăˇă§ăłăŻăpythonă˘ă¸ăĽăźăŤăĺŽčĄăăă¨ăăŤä˝żăăžăăč¨çŽçľäşăžă§ćéăăăăăŽă§ăć°éˇăŤĺž
ăŁăŚăă ăăă
Macä¸ăŽăăĄă¤ăŤăŤă˘ăŻăťăšăă
äťĺşŚăŻăčŞĺăć¸ăăTensorFlowç¨pythonăšăŻăŞăăăĺăăăžăăăăŽĺ ´ĺăăăšăďźăăă§ăŻMacăăˇăłďźăŽăăŁăŹăŻăăŞăćĺŽăăăłăłăăĺ ăŽăăĄă¤ăŤăˇăšăă ăŤăăŚăłăăăăă¨ăăćšćłăă¨ăăžăăăžăăăăźăŤăŤăŽPCăŽăăĺ ´ćďźăăă§ăŻ/Users/TensorFlowďźăŤă䝼ä¸ăŽăăăŞăăĄă¤ăŤăä˝ăăžăă
test.py
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print sess.run(hello)
ă¤ăăŤă
docker run -v /Users/TensorFlow:/tensorflow_dev -it b.gcr.io/tensorflow/tensorflow
ă¨ăăă¨ăăăźăŤăŤăŽTensorFlowăăŠăŤăăăłăłăăĺ
ăŽtensorflow_devăăŠăŤăăŤăăŚăłăăăăŚăăłăłăăăä˝ćăăăžăă
ăˇă§ăŤăŤĺ
ĽăŁăăls /tensor_flow
ă§test.pyăăăăă¨ă確čŞăăŚăă ăăă
大ä¸ĺ¤ŤăŞăăpython /tensorflow_dev/test.py
ă§ăšăŻăŞăăăčľ°ăăăžăăăăăăăă¨ăŠăźăĄăăťăźă¸ăĺşăăăăăšăďźMacďźä¸ă§test.py
ă俎ćŁăăŚăťăźăăăă°ăăłăłăăĺ
ăŽtensorflow_dev
ăŽtest.py
ăŤăĺ¤ć´ăĺć ăăăžăăăăžăăăă°ăHello TensorFlow!
ăŽăĄăăťăźă¸ăĺşăăŻăă§ăă
ăăăăŤ
ă¨ăăăăăćŠć˘°ĺŚçżăŠăăăDockerăLinuxăćŞăăç§ă§ăăćä˝éăŽä˝ćĽăŻă§ăăăă§ăă揥ăŻăăĺ°ăĺ ˇä˝çăŞĺéĄăŤă¤ăăŚĺăçľăă§ăżăžăăăă¨ăWindowsă§ăĺăăăŚăżăăăăŞă