Skip to content

Commit e572d13

Browse files
Apply suggestions from code review
Co-authored-by: manugaursharma <[email protected]>
1 parent 7595b2c commit e572d13

File tree

1 file changed

+72
-45
lines changed

1 file changed

+72
-45
lines changed

com.unity.ml-agents/Documentation~/Installation.md

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,69 @@
11
# Installation
2-
To install and use the ML-Agents Toolkit, follow the steps below. Detailed instructions for each step are provided later on this page.
2+
Set up your system to use the ML-Agents Toolkit to train and evaluate machine-learning agents in Unity projects.
33

4-
1. Install Unity (6000.0 or later)
5-
2. Install Python using conda (>= 3.10.1, <=3.10.12) - we recommend using 3.10.12
6-
3. Install ML-Agents using one of the following methods:
4+
This process includes installing Unity, configuring Python, and installing the ML-Agents packages. Follow the steps in order to ensure compatibility between Unity and the ML-Agents components.
75

8-
3.1 Package installation
96

10-
3.2 Advanced installation
117

12-
## 1. Install **Unity 6000.0** or Later
8+
## Install Unity
139

14-
[Download](https://unity3d.com/get-unity/download) and install Unity. We strongly recommend that you install Unity through the Unity Hub as it will enable you to manage multiple Unity versions.
10+
Install Unity 6000.0 or later to use the ML-Agents Toolkit.
1511

16-
## 2. Install **Python 3.10.12** using Conda
12+
To install Unity, follow these steps:
1713

18-
We recommend using [conda](https://docs.conda.io/en/latest/) or [mamba](https://github.com/mamba-org/mamba) to install and manage Python environments.
14+
1. [Download Unity](https://unity3d.com/get-unity/download).
15+
2. Use the Unity Hub to manage installations and versions.
16+
Unity Hub makes it easier to manage multiple Unity versions and associated projects.
17+
4. Verify that the Unity Editor version is 6000.0 or later.
1918

20-
Once conda has been installed on your system, open a terminal and execute the following commands to set up a Python 3.10.12 virtual environment and activate it:
19+
## Install Python 3.10.12 using Conda
2120

22-
```shell
23-
conda create -n mlagents python=3.10.12 && conda activate mlagents
24-
```
21+
Use Conda or Mamba to install and manage your Python environment. This ensures that ML-Agents dependencies are isolated and version-controlled.
2522

26-
On Windows, you'll have to install the PyTorch package separately prior to installing ML-Agents in order to make sure the cuda-enabled version is used, rather than the CPU-only version. Activate your virtual environment and run from the command line:
23+
To install Python, follow these steps:
2724

28-
```sh
29-
pip3 install torch~=2.2.1 --index-url https://download.pytorch.org/whl/cu121
30-
```
25+
1. Install [Conda](https://docs.conda.io/en/latest/) or [Mamba](https://github.com/mamba-org/mamba).
26+
2. Open a terminal and create a new Conda environment with Python 3.10.12:
27+
28+
```shell
29+
conda create -n mlagents python=3.10.12 && conda activate mlagents
30+
31+
32+
33+
34+
## Install ML-Agents
35+
You can install ML-Agents in two ways:
36+
37+
* Package installation: Recommended for most users who want to use ML-Agents without modifying the source code.
38+
* Advanced installation: For contributors, developers extending ML-Agents, or users who want access to the example environments.
39+
40+
### Install ML-Agents (Package installation)
41+
42+
Use this method if you don’t plan to modify the toolkit or need the example environments.
43+
44+
#### Install the Unity package
45+
46+
To install the package, follow these steps:
47+
48+
1. In Unity, open **Window** > **Package Manager**.
49+
2. Select **+** > **Add package by name**.
50+
3. Enter `com.unity.ml-agents`.
51+
4. Enable **Preview Packages** under the **Advanced** drop-down list if the package doesn’t appear.
3152

32-
Note that on Windows, you may also need Microsoft's Visual C++ Redistributable if you don't have it already. See the [PyTorch installation guide](https://pytorch.org/get-started/locally/) for more installation options and versions.
53+
If the package isn’t listed, follow the [Advanced Installation](#32-install-ml-agents---advanced-installation) method instead.
3354

3455

35-
## 3.1 Install ML-Agents - Package Installation
36-
Use this installation method if you do not plan to modify or extend the ML-Agents Toolkit for your purposes and you don't need access to our example environments.
3756

38-
### 3.1.1 Install the `com.unity.ml-agents` Unity package
57+
### Install the Python package
3958

40-
The Unity ML-Agents C# SDK is a Unity Package. You can install the `com.unity.ml-agents` package [directly from the Package Manager registry](https://docs.unity3d.com/Manual/upm-ui-install.html). Please make sure you enable 'Preview Packages' in the 'Advanced' dropdown in order to find the latest Preview release of the package.
59+
Install the ML-Agents Python package to enable communication between Unity and your machine learning training environment.
4160

42-
**NOTE:** If you do not see the ML-Agents package listed in the Package Manager please follow the [Advanced Installation](#32-install-ml-agents---advanced-installation) instructions at the bottom of this page.
61+
Using a Python virtual environment helps isolate project dependencies and prevent version conflicts across your system. Virtual environments are supported on macOS, Windows, and Linux. For more information, refer to [Using Virtual Environments](https://github.com/Unity-Technologies/ml-agents/pull/6242/files/Using-Virtual-Environment.md).
4362

44-
### 3.1.2 Install Python package
63+
1. Before installing ML-Agents, activate the Conda environment you created:
4564

46-
Installing the `mlagents` Python package involves installing other Python packages that `mlagents` depends on. So you may run into installation issues if your machine has older versions of any of those dependencies already installed. Consequently, our supported path for installing `mlagents` is to leverage Python Virtual Environments. Virtual Environments provide a mechanism for isolating the dependencies for each project and are supported on Mac / Windows / Linux. We offer a dedicated [guide on Virtual Environments](Using-Virtual-Environment.md).
4765

48-
You can install the ML-Agents Python package directly from PyPi.
4966

50-
**Important:** Ensure you install a Python package version that matches your Unity package version. Check the [release history](https://github.com/Unity-Technologies/ml-agents/releases) to find compatible versions.
5167

5268
To install, activate your virtual environment and run the following command:
5369

@@ -61,43 +77,54 @@ which will install the latest version of ML-Agents Python packages and associate
6177
conda install "grpcio=1.48.2" -c conda-forge
6278
```
6379

64-
When you install the Python package, the dependencies listed in the [setup.py file](https://github.com/Unity-Technologies/ml-agents/blob/release/4.0.0/ml-agents/setup.py) are also installed. These include [PyTorch](Background-PyTorch.md).
6580

6681

67-
## 3.2 Install ML-Agents - Advanced Installation
82+
### Install ML-Agents (Advanced Installation)
83+
84+
Use the advanced installation method if you plan to modify or extend the ML-Agents Toolkit, or if you want to download and use the example environments included in the repository.
85+
86+
#### Clone the ML-Agents repository
87+
88+
Clone the ML-Agents repository to access the source code, sample environments, and development branches.
89+
90+
To clone the latest stable release, run:
6891

69-
You will need to clone the repository if you plan to modify or extend the ML-Agents Toolkit for your purposes, or if you'd like to download our example environments. Some of our tutorials / guides assume you have access to our example environments.
7092

7193
Use the command below to clone the repository:
7294

7395
```sh
7496
git clone --branch release_23 https://github.com/Unity-Technologies/ml-agents.git
7597
```
7698

77-
The `--branch release_23` option will switch to the tag of the latest stable release. Omitting that will get the `develop` branch which is potentially unstable. However, if you find that a release branch does not work, the recommendation is to use the `develop` branch as it may have potential fixes for bugs and dependency issues.
7899

79-
To get the bleeding-edge development version (optional):
80100

81-
```sh
82-
git clone https://github.com/Unity-Technologies/ml-agents.git
83-
```
84101

85-
If you plan to contribute those changes back, make sure to clone the `develop` branch (by omitting `--branch release_23` from the command above). See our [Contributions Guidelines](CONTRIBUTING.md) for more information on contributing to the ML-Agents Toolkit.
102+
#### Add the ML-Agents Unity package
103+
104+
After cloning the repository, add the `com.unity.ml-agents` Unity package to your project.
86105

87-
### 3.2.1 Add the `com.unity.ml-agents` Unity package
88-
You can [add the local](https://docs.unity3d.com/Manual/upm-ui-local.html) `com.unity.ml-agents` package (from the repository that you just cloned) to your project by:
106+
To add the local package, follow these steps:
89107

90-
1. Navigating to the menu `Window` -> `Package Manager`.
91-
2. In the package manager window, click on the `+` button on the top left of the packages list.
92-
3. Select `Add package from disk...`
93-
4. Navigate into the `com.unity.ml-agents` folder.
108+
1. In the Unity Editor, go to **Window** > **Package Manager**.
109+
2. In the **Package Manager** window, select **+**.
110+
3. Select **Add package from disk**.
111+
4. Navigate to the cloned repository and open the `com.unity.ml-agents` folder.
94112
5. Select the `package.json` file.
95113

114+
Unity adds the ML-Agents package to your project.
115+
116+
If you plan to use the example environments provided in the repository, open the **Project** folder in Unity to explore and experiment with them.
117+
118+
96119
<p align="center"> <img src="images/unity_package_manager_window.png" alt="Unity Package Manager Window" height="150" border="10" /> <img src="images/unity_package_json.png" alt="package.json" height="150" border="10" /> </p>
97120

98-
If you are going to follow the examples from our documentation, you can open the `Project` folder in Unity and start tinkering immediately.
99121

100-
### 3.2.2 Install Python package
122+
#### Install the ML-Agents Python package
123+
124+
Install the Python packages from the cloned repository to enable training and environment communication.
125+
126+
1. From the root of the cloned repository, activate your virtual environment and run:
127+
101128

102129
To install the `mlagents` Python package, activate your virtual environment and run from the command line:
103130

0 commit comments

Comments
 (0)