LoginSignup
3
6

More than 3 years have passed since last update.

Python + Unity 強化学習環境構築

Last updated at Posted at 2020-09-14

PythonでML-Agentを動かすための環境構築

使用環境

Python 3.7.6
mlagents 0.17.0
ML-Agents Release3
Unity 2019.2.21f1
Pyenv
Poetry

前提条件

Unity Hubのダウンロード

1.Unity ML-Agentsのインストール

(1)以下のサイトからUnity ML-Agents Release3をインストールする
https://github.com/Unity-Technologies/ml-agents

スクリーンショット 2020-09-14 130014.png
スクリーンショット 2020-09-14 130030.png

(2)コピーしたURLをGit cloneコマンドの後ろに付けて実行 ファイル一式をダウンロードできる
(※git clone する前に作業をするディレクトリを作成!)

terminal
mkdir [任意のディレクトリ名]
cd [ディレクトリ名]
git clone [コピーしたURL]

(3)ml-agentsディレクトリが作成され、中に以下のようなファイルが入っていることを確認!
スクリーンショット 2020-09-14 131106.png

2.Python3.7.6の仮想環境の構築!

(1)pyenvをインストール!

terminal
brew install pyenv

(2)Python3.7.6のインストール

terminal
pyenv install 3.7.6

(3)このディレクトリはPython3.7.6で実行することを設定

terminal
pyenv local 3.7.6

(4)Pythonの管理パッケージPoetryをダウンロード&インストール

terminal
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

(5)Poetryの仮想環境準備
設定を確認
スクリーンショット 2020-09-14 134557.png
プロジェクト内に仮想環境が作られるように設定し、再び設定状態を確認

terminal
poetry config virtualenvs.in-project true

(6)Python3.7.6で仮想環境構築
スクリーンショット 2020-09-14 132533.png

(7)mlagent==0.17.0のインストール!

terminal
poetry add mlagents==0.17.0

(7)mlagents-learnコマンドが実行できることを確認
下のコマンド実行後下の画像のようなものが出てくることを確認

terminal
mlagents-learn

スクリーンショット 2020-09-14 132912.png

3
6
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
3
6