LoginSignup
5
5

More than 5 years have passed since last update.

MXNetチュートリアル(gluon部)用の環境構築

Last updated at Posted at 2017-07-17

TL;DR

【2017/07/26追記】
上記gluonを用いたチュートリアルは公式より一旦下げられ、http://thestraightdope.mxnet.io でホストされる模様です。

Dockerfile

FROM ubuntu:16.04 

RUN groupadd mxnet && useradd -m -g mxnet mxnet
RUN apt-get update && apt-get install -y\
    build-essential\
    git\
    libopenblas-dev\
    liblapack-dev\
    libopencv-dev\
    python3-dev\
    python3-setuptools\
    python3-numpy\
    python3-pip\
    graphviz

# MXNetインストール
RUN git clone --recursive https://github.com/dmlc/mxnet
WORKDIR mxnet
RUN make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas
WORKDIR /mxnet/python
RUN pip3 install --upgrade pip
RUN pip3 install -e .

RUN pip3 install \
    jupyter \
    matplotlib \
    graphviz
    # Python3環境実行

RUN mkdir /home/mxnet/mxnet-tutorials
RUN chown -R mxnet:mxnet /home/mxnet
WORKDIR /home/mxnet/mxnet-tutorials

EXPOSE 8888
USER mxnet

CMD ["/usr/local/bin/jupyter", "notebook",\
    "--notebook-dir=/home/mxnet/mxnet-tutorials",\ 
    "--ip='*'",\
    "--port=8888",\ 
    "--no-browser"]

起動手順

  1. docker環境を事前に構築(dockerサイトなど参照)
  2. Dockerfileをカレントディレクトリに配置
  3. ビルド
    docker build -t mxnet-tutorials .
  4. 起動
    docker run\ -v $(pwd):/home/mxnet/mxnet-tutorials\ -p 8888:8888\ --rm\ mxnet-tutorials
  5. 表示されるlocalhost:8888/?token=... へブラウザへアクセスするとJupyterが起動している(ハズ)

Why

2017/7/17時点でリリースされている0.10.0では、チュートリアルが実行できなかっため構築(公式Dockerイメージもv0.10.0)

gluonとは

Gluon Package

Gluon package is a high-level interface for MXNet designed to be easy to use while keeping most of the flexibility of low level API. Gluon supports both imperative and symbolic programming, making it easy to train complex models imperatively in Python and then deploy with symbolic graph in C++ and Scala.

高レベルインターフェースを提供するパッケージ(まだ実験的なため、変更の可能性ありとのこと…ならチュートリアルトップに載せなくても)

このチュートリアルでは、PyTorchのような実行時に勾配を自動で計算してくれるパッケージ(autograd)も利用するのですが、これも0.10.0では対応していない(というのは語弊があり、深い位置に配置されている模様…)ので、2017/7/17現在はmasterブランチからビルドする必要があるようです。

チュートリアルもtypoがちょこちょこあるなど荒削りで、変更されていく可能性は高そうです。試してみる方はご注意ください。

5
5
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
5
5