I had touched ML-Agents, but it was different from when I touched it before, so I tried to organize how to build the environment.
There are various commentary sites, but in the end, they were all written on the official website! Although it is in English, I read it with the help of Google teacher lol Installation
Although it is written in the official manual, 1 and 3, 2 and 4 are a set, so it is okay to change the order. (Like 2 → 4 → 1 → 3)
Use Unity Hub to install newer than 2018.4. I have installed the latest LTS version 2019.4.10f1 at the moment (September 15, 2020).
I installed the latest version of Python 3.7 series from the official website. From the table that says "Looking for a specific release?", I think you should download the one at the top of the 3.7.x series (the one that was recently updated). Be sure to download the 64-bit version (the one labeled x64-86).
Install the package in the Unity Project. This is much easier to understand than it used to be. ~~ (In the old days, it wasn't intuitive to install barracuda) ~~
Open the project you want to use ML-Agents in Unity.
Click "Window-> Package Manager" from the menu bar to open Package Manager. Then, check if the red part in the image below is the same.
Then search for "ML-Agents" in the search box at the top right. Then, I think that the package of ML Agents will come out, so select it and install it from the install button at the bottom right.
This completes the installation of ML-Agents Unity Package. (It also installs dependent packages such as Barracuda at once.)
ML-Agents seems to use various modules of Python, and it seems that it may not work well if it is already installed (for example, the numpy module does not support the latest version), so there is no such thing. If you don't understand, let's build a virtual environment quietly. It is easy to handle when the version of ML-Agents changes.
Previously, I was told to create an environment with Anaconda, but now it seems that it is recommended to use venv.
We do not provide support for Anaconda installation on Windows.
So, I will build a virtual environment using venv.
How to build a virtual environment is also described in the official manual, "Using Virtual Environment It is written in. Kindness!
Install pip for the official procedure! It says, but it seems that it is installed as standard in Python 3.4 or later, so I will omit it.
To put it simply, pip is a convenient module management tool (install, update, uninstall etc ...).
First, create a folder to save the virtual environment. Move the current directory to the location where you want to create the folder in advance. I create it under my user folder (C: \ Users \ username).
Enter the following command at the command prompt or Powershell. Then, I think that a folder called "python-envs" was created.
md python-envs
Next, create a virtual environment. Enter the command below. This will create a virtual environment named "mlagents-release6". Please change this "mlagents-release6" part to your favorite name. By the way, it is "sample-env" in the official manual.
py -3.7 -m venv python-envs\mlagents-release6
Next, let's use the virtual environment created earlier. This operation is called "activate". If you don't do this, you'll get "Oh, I installed the module last time, but I can't use it", so please be careful.
.\python-envs\mlagents-release6\Scripts\activate
Execute the above command, and when the name of the virtual environment is displayed before writing the command as shown below, activation is complete.
PS C:\Users\kamekyame>
#After activation ↓
(mlagents-release6) PS C:\Users\kamekyame>
From here, we will proceed on the assumption that the virtual environment is activated.
Upgrade pip in the virtual environment to the latest version. Execute the following command.
pip install --upgrade pip
Depending on the person, the following error may appear, but it seems that pip has been upgraded for the time being, so don't worry, leave it for the time being.
ERROR: Could not install packages due to an EnvironmentError: [WinError 5]Access denied.
Finally, it is the installation of mlagents. This area is also much easier than it used to be, and all dependent modules can now be installed with a single command line. Execute the command below.
pip install mlagents
After a while, the message Successfully installed
will be displayed and the installation will be completed.
The following ERROR may appear above this Successfully installed
.
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.
We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.
mlagents-envs 0.19.0 requires numpy<1.19.0,>=1.14.1, but you'll have numpy 1.19.2 which is incompatible.
tensorflow 2.3.0 requires numpy<1.19.0,>=1.16.0, but you'll have numpy 1.19.2 which is incompatible.
Well, if you ask Google teacher, it will be translated, but this is because the version of numpy already installed was 1.19.0, but with mlagents-envs and tensorflow module 1.16.0 ~ 1.1.9 (1.19) It is said that .0 is not included) is not supported.
So change the version of numpy to a version lower than 1.19.0. Execute the following command.
pip install numpy==1.18.5
This is the end of environment construction!
This is the end of environment construction!
After that, use the mlagents-learn
command to have a good machine learning life.
The first wall "environment construction" that you come across to do new things! ML-Agents is no exception, and it's a little confusing, but if you read the official manual carefully, you can do it properly.
ML-Agents has a lot of official manuals, and you can find out what you want to know from the official manuals. In fact, ML-Agents have many specification changes and often cannot be used with older versions of code. When looking up ML-Agents, it's a good idea to look at the official version or check the version of ML-Agents for someone's article!
I'll put a few links that I think I'll use in the end. Thank you for visiting so far m (_ _) m
Unity ML-Agents Github Unity ML-Agents Release 6 Source code & Sample code download page Unity ML-Agents Toolkit Documentation ← This is all Unity ML-Agents Installation Documentation