Skip to content

Instantly share code, notes, and snippets.

@witt3rd
Last active May 5, 2021 19:36
Show Gist options
  • Save witt3rd/4f85c3dad9f66d8acd3242e2b6fb1782 to your computer and use it in GitHub Desktop.
Save witt3rd/4f85c3dad9f66d8acd3242e2b6fb1782 to your computer and use it in GitHub Desktop.
Unity

Unity

Setup

  • Install the Unity Hub
  • Use the hub to install the latest LTS (long-term support) editor (e.g., 2020.3.6f1 LTS)
  • No additional modules are needed during the editor install, so accept the defaults

Projects

New

  • Use the hub to add a NEW project
    • Specify the location for the project
    • The default editor will be used

Existing

  • Use the hub to ADD an existing project
    • Select the folder that contains the project and it will import it and launch the editor

Git

  • When using git, be sure to include a Unity-specific .gitignore, as Unity projects include many large intermediate files that are not necessary to preserve in a repo

Main Concepts

Packages

ML-Agents Toolkit

Python

ML-Agents requires use of Python. There are a variety of ways to get Python working on your system, depending on OS, package manager, IDE, or data science environment (e.g., Anaconda). We won't cover them all here, rather just provide a few notes that might be useful, depending on your circumstances.

Note that the Python setup instructions suggest to create a system-wide virtual environments folder (e.g., ~/python-envs), we prefer to keep virtual environments within a repo/project root

Virtual environments are specific to each user, so they are excluded from the git repository and you should create your own. The project-level .gitignore excludes the venv directory at the repo/project root

For the latest version of Python, check the official releases page, which is useful when using pyenv to manage version (see below), or with pyenv itself:

pyenv install --list
macOS

From The right and wrong way to set python 3 as default on a mac:

pyenv install 3.9.4
pyenv global 3.9.4

Add the following to your .bashrc, .bash_profile, .zshrc, or whatever is your preference:

if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi

Confirm after sourcing or opening a new terminal:

python --version
Python 3.9.4

To activate the environment:

source venv/bin/activate

and note that your prompt has been modified with a prefix of venv.

Windows

The official Python installer can be used to install the latest version.

Be sure to "Install for all users" in order to use virtual environments (venv) due to this issue.

mlagents Python Packages

First, ensure you have the latest pip (within your virtual environment):

python -m pip install --upgrade pip

Install PyTorch (Windows Only):

pip3 install torch~=1.7.1 -f https://download.pytorch.org/whl/torch_stable.html

Install the mlagents Python package:

python -m pip install mlagents==0.26.0

This will install all the required dependencies (e.g., PyTorch, Tensorboard).

Confirm the installation was successful with the following command (it might take awhile):

mlagents-learn --help

Training

mlagents-learn --run-id=<model name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment