LoginSignup
1
2

More than 5 years have passed since last update.

Unity ml-agents v0.6.0 setup for windows

Last updated at Posted at 2018-12-22

Unity で使えるmachine learningのライブラリです
GitHub - Unity-Technologies/ml-agents: Unity Machine Learning Agents Toolkit

widnowsでのセットアップ手順を書きますが、基本的に下記リンクそのままです。
ml-agents/Installation-Windows.md at master · Unity-Technologies/ml-agents · GitHub

下記の流れでセットアップしていきます。

1. anacondaを使ってPythonのセットアップ
2. tensorflowのインストール
3. ml-agentsをclone
4. 必要なライブラリ群をインストール

1. anacondaをつかってPythonのセットアップ


anaconda のセットアップ
気を付けなければならないのは、Pythonのバージョンで、Python 3.6 又は Python 3.5を使いましょうとのことです。(2系は対応していないみたいです)
anaconda は下記リンクからダウンロードできます。
Python 3.7 versionを選べば問題ないかと思います。
Downloads - Anaconda

インストールが終わったら一度 Anaconda Navigatorを開きましょう。
Windows search bar に Anaconda Navigator と打てば見つかるかと思います。
その後、Anaconda Navigatorは閉じてしまって構いません。

次に、conda コマンドを使えるように下記のpathを通します。
環境変数とWindows search bar に打てば環境変数を編集するコントロールパネルが出るかと思います。

%UserProfile%\Anaconda3\Scripts
%UserProfile%\Anaconda3\Scripts\conda.exe
%UserProfile%\Anaconda3
%UserProfile%\Anaconda3\python.exe

上記のpathを通せば、 condaコマンドが使えるようになるはずです。

Pythonのセットアップ
上記の手順でcondaコマンドが使えるようになったはずですので、
下記コマンドでPythonの環境を作ります。(ちなみに自分はpowershellをつかいました)
conda create -n ml-agents python=3.6
上記コマンドで "ml-agents"という名前の環境が作られたので、この環境を使用するために下記コマンドを打ちます
activate ml-agents

(ml-agents) >

コマンドプロンプトが上記の様になるかと思います。(deactivate と打てば元に戻ります)

2. tensorflowのインストール


モデルの学習時にtensorflowを使用します。
ここで注意が必要なのはtensorflowのバージョンです。
対応しているのは1.7.1で、これはUnityのml-agentsリポジトリがこのバージョンをしていしています。
pip install tensorflow==1.7.1
上記コマンドtensorflowがインストールされます.

3. ml-agentsをclone

git clone https://github.com/Unity-Technologies/ml-agents.git

4. 必要なライブラリ群をインストール

clone したディレクトリの中に、ml-agentsディレクトリがあるのでそこに移動してください.
PATH_TO_CLONE\ml-agents\ml-agents

下記を参考にしていただければと思います。

(ml-agents) > ls


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2018/12/21     21:41                mlagents
d-----       2018/12/21     21:41                tests
-a----       2018/12/21     21:41           1269 README.md
-a----       2018/12/21     21:41           1393 setup.py

ここで
pip install -e .
と打てば必要なライブラリがインストールされます。

試しに、
mlagents-learn
と打ってみてください。
下記の様に返ってきたら、セットアップ完了です。


                        ▄▄▄▓▓▓▓
                   ╓▓▓▓▓▓▓█▓▓▓▓▓
              ,▄▄▄m▀▀▀'  ,▓▓▓▀▓▓▄                           ▓▓▓  ▓▓▌
            ▄▓▓▓▀'      ▄▓▓▀  ▓▓▓      ▄▄     ▄▄ ,▄▄ ▄▄▄▄   ,▄▄ ▄▓▓▌▄ ▄▄▄    ,▄▄
          ▄▓▓▓▀        ▄▓▓▀   ▐▓▓▌     ▓▓▌   ▐▓▓ ▐▓▓▓▀▀▀▓▓▌ ▓▓▓ ▀▓▓▌▀ ^▓▓▌  ╒▓▓▌
        ▄▓▓▓▓▓▄▄▄▄▄▄▄▄▓▓▓      ▓▀      ▓▓▌   ▐▓▓ ▐▓▓    ▓▓▓ ▓▓▓  ▓▓▌   ▐▓▓▄ ▓▓▌
        ▀▓▓▓▓▀▀▀▀▀▀▀▀▀▀▓▓▄     ▓▓      ▓▓▌   ▐▓▓ ▐▓▓    ▓▓▓ ▓▓▓  ▓▓▌    ▐▓▓▐▓▓
          ^█▓▓▓        ▀▓▓▄   ▐▓▓▌     ▓▓▓▓▄▓▓▓▓ ▐▓▓    ▓▓▓ ▓▓▓  ▓▓▓▄    ▓▓▓▓`
            '▀▓▓▓▄      ^▓▓▓  ▓▓▓       └▀▀▀▀ ▀▀ ^▀▀    `▀▀ `▀▀   '▀▀    ▐▓▓▌
               ▀▀▀▀▓▄▄▄   ▓▓▓▓▓▓,                                      ▓▓▓▓▀
                   `▀█▓▓▓▓▓▓▓▓▓▌
                        ¬`▀▀▀█▓

Usage:
      mlagents-learn <trainer-config-path> [options]
      mlagents-learn --help
1
2
1

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
1
2