LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

[Singularity Hands-on] case2: Singularity で tensorflowを動かそう (--writable ビルド, shell編)

Last updated at Posted at 2018-01-21

case2では、ソースは "Local Container"を用い、実行は "shell" コマンド でコンテナーにログインしTensorflowを起動します。また、本ページの親ページはこちらにあります。

Kobito.KseEfi.png

前提条件

Singularity がインストールされていること

Hands-on1 で作成した local上のcontainer から writableなSingularityコンテナーを作成する

Singularity コンテナーの作成

command@host
CONTAINER_NAME="wcontainer.img"
SOURCE_IMAGE="container.img"
command@host
sudo singularity build --writable ${CONTAINER_NAME} ${SOURCE_IMAGE}

生成物の確認

生成物として、Singularity用のイメージがあることを確認します。

command@host
ls -l ${CONTAINER_NAME}
response@host
-rwxr-xr-x 1 root root 1668284447 Jan 21 04:23 wcontainer.img

コンテナーの ubuntu を update する

--wirtable でコンテナーを作成したので、コンテナー内のイメージをアップデートしてみます。

command@host
sudo singularity shell --writable ${CONTAINER_NAME}
command@container
apt-get update
command@container
exit

Tensorflowの実行 (shellコマンド経由)

MNISTのサンプルスクリプトのダウンロード

command@host
wget https://raw.githubusercontent.com/tensorflow/tensorflow/r1.4/tensorflow/examples/tutorials/mnist/mnist_softmax.py

shell コマンドでコンテナーにログイン

command@host
singularity shell ${CONTAINER_NAME}
response@host
Singularity: Invoking an interactive shell within container...

MNIST on tensorflow の実行

インストールされたtensorflowを用いてMNISTを実行します。

mnist_softmax.py を実行します。

command@container
python mnist_softmax.py 
response@container
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
FINISH MNIST 0.9185
command@container
exit
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up