Skip to content

Commit 98338f2

Browse files
Added no graphics monitor feature. (#6014)
* Added no graphics monitor feature. * Fixed precommit issues. * Fixed installation docs for incorrect python version causing conflicts in Windows.
1 parent 643df35 commit 98338f2

File tree

14 files changed

+77
-36
lines changed

14 files changed

+77
-36
lines changed

docs/Installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ Consequently, to install and use the ML-Agents Toolkit you will need to:
4343
strongly recommend that you install Unity through the Unity Hub as it will
4444
enable you to manage multiple Unity versions.
4545

46-
### Install **Python 3.10.12** or Higher
46+
### Install **Python 3.10.12**
4747

48-
We recommend [installing](https://www.python.org/downloads/) Python 3.10.
48+
We recommend [installing](https://www.python.org/downloads/) Python 3.10.12.
4949
If you are using Windows, please install the x86-64 version and not x86.
5050
If your Python environment doesn't include `pip3`, see these
5151
[instructions](https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers)
5252
on installing it. We also recommend using [conda](https://docs.conda.io/en/latest/) or [mamba](https://github.com/mamba-org/mamba) to manage your python virtual environments.
5353

5454
#### Conda python setup
5555

56-
Once conda has been installed in your system, open a terminal and execute the following commands to setup a python 3.10 virtual environment
56+
Once conda has been installed in your system, open a terminal and execute the following commands to setup a python 3.10.12 virtual environment
5757
and activate it.
5858

5959
```shell
60-
conda create -n mlagents python=3.10 && conda activate mlagents
60+
conda create -n mlagents python=3.10.12 && conda activate mlagents
6161
```
6262

6363
### Clone the ML-Agents Toolkit Repository (Recommended)

docs/Migrating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
TODO: update ml-agents-env package version before release
66
--->
77
## Migrating to the ml-agents-envs 0.30.0 package
8-
- Python 3.10 is now the minimum version of python supported due to [python3.6 EOL](https://endoflife.date/python).
8+
- Python 3.10.12 is now the minimum version of python supported due to [python3.6 EOL](https://endoflife.date/python).
99
Please update your python installation to 3.10.12 or higher.
1010
- The `gym-unity` package has been refactored into the `ml-agents-envs` package. Please update your imports accordingly.
1111
- Example:

docs/Python-LLAPI-Documentation.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -634,22 +634,21 @@ class UnityEnvironment(BaseEnv)
634634
#### \_\_init\_\_
635635

636636
```python
637-
| __init__(file_name: Optional[str] = None, worker_id: int = 0, base_port: Optional[int] = None, seed: int = 0, no_graphics: bool = False, timeout_wait: int = 60, additional_args: Optional[List[str]] = None, side_channels: Optional[List[SideChannel]] = None, log_folder: Optional[str] = None, num_areas: int = 1)
637+
| __init__(file_name: Optional[str] = None, worker_id: int = 0, base_port: Optional[int] = None, seed: int = 0, no_graphics: bool = False, no_graphics_monitor: bool = False, timeout_wait: int = 60, additional_args: Optional[List[str]] = None, side_channels: Optional[List[SideChannel]] = None, log_folder: Optional[str] = None, num_areas: int = 1)
638638
```
639639

640640
Starts a new unity environment and establishes a connection with the environment.
641641
Notice: Currently communication between Unity and Python takes place over an open socket without authentication.
642642
Ensure that the network where training takes place is secure.
643643

644-
:string file_name: Name of Unity environment binary.
645-
:int base_port: Baseline port number to connect to Unity environment over. worker_id increments over this.
646-
If no environment is specified (i.e. file_name is None), the DEFAULT_EDITOR_PORT will be used.
647-
:int worker_id: Offset from base_port. Used for training multiple environments simultaneously.
648-
:bool no_graphics: Whether to run the Unity simulator in no-graphics mode
649-
:int timeout_wait: Time (in seconds) to wait for connection from environment.
650-
:list args: Addition Unity command line arguments
651-
:list side_channels: Additional side channel for no-rl communication with Unity
652-
:str log_folder: Optional folder to write the Unity Player log file into. Requires absolute path.
644+
:string file_name: Name of Unity environment binary. :int base_port: Baseline port number to connect to Unity
645+
environment over. worker_id increments over this. If no environment is specified (i.e. file_name is None),
646+
the DEFAULT_EDITOR_PORT will be used. :int worker_id: Offset from base_port. Used for training multiple
647+
environments simultaneously. :bool no_graphics: Whether to run the Unity simulator in no-graphics mode :bool
648+
no_graphics_monitor: Whether to run the main worker in graphics mode, with the remaining in no-graphics mode
649+
:int timeout_wait: Time (in seconds) to wait for connection from environment. :list args: Addition Unity
650+
command line arguments :list side_channels: Additional side channel for no-rl communication with Unity :str
651+
log_folder: Optional folder to write the Unity Player log file into. Requires absolute path.
653652

654653
<a name="mlagents_envs.environment.UnityEnvironment.close"></a>
655654
#### close

docs/Tutorial-Custom-Trainer-Plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ mlagents-learn ml-agents-trainer-plugin/mlagents_trainer_plugin/a2c/a2c_3DBall.y
260260
```
261261

262262
### Validate your implementations:
263-
Create a clean Python environment with Python 3.10+ and activate it before you start, if you haven't done so already:
263+
Create a clean Python environment with Python 3.10.12 and activate it before you start, if you haven't done so already:
264264
```shell
265265
conda create -n trainer-env python=3.10.12
266266
conda activate trainer-env

localized_docs/KR/docs/Installation-Anaconda-Windows.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ML-Agents toolkit�� ����ϱ� ����, �Ʒ��� ���
1313
Windows ������ Anaconda�� [�ٿ�ε�](https://www.anaconda.com/download/#windows)�ϰ� ��ġ�Ͻʽÿ�.
1414
Anaconda�� ��������ν�, �ٸ� ���� ������ Python�� �и��� ȯ�濡�� ������ �� �ֽ��ϴ�.
1515
Python 2�� ���̻� �������� �ʱ� ������ Python 3.10�� �ʿ��մϴ�. �� ���̵忡�� �츮��
16-
Python 3.10 ������ Anaconda 5.1 ������ ����� ���Դϴ�.
16+
Python 3.10.12 ������ Anaconda 5.1 ������ ����� ���Դϴ�.
1717
([64-bit](https://repo.continuum.io/archive/Anaconda3-5.1.0-Windows-x86_64.exe)
1818
�Ǵ� [32-bit](https://repo.continuum.io/archive/Anaconda3-5.1.0-Windows-x86.exe)
1919
��ũ).
@@ -65,11 +65,11 @@ ML-Agents toolkit�� �Բ� ����� ���ο� [Conda ȯ��]
6565
��ɾ Ÿ���� �Ͻʽÿ�:
6666

6767
```sh
68-
conda create -n ml-agents python=3.10
68+
conda create -n ml-agents python=3.10.12
6969
```
7070

7171
�� ��Ű���� ��ġ�ϱ� ���� �޼����� ���� ��� `y`�� Ÿ�����ϰ� ���͸� �����ʽÿ� _(���ͳ��� ����Ǿ��ִ��� Ȯ���Ͻʽÿ�)_.
72-
�� �䱸�Ǵ� ��Ű������ �ݵ�� ��ġ�ؾ� �մϴ�. ���ο� Conda ȯ�濡�� Python 3.10 ������ ���Ǹ� ml-agents�� ȣ��˴ϴ�.
72+
�� �䱸�Ǵ� ��Ű������ �ݵ�� ��ġ�ؾ� �մϴ�. ���ο� Conda ȯ�濡�� Python 3.10.12 ������ ���Ǹ� ml-agents�� ȣ��˴ϴ�.
7373

7474
<p align="center">
7575
<img src="images/conda_new.PNG" alt="Anaconda Install" width="500" border="10" />

localized_docs/KR/docs/Installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ git clone https://github.com/Unity-Technologies/ml-agents.git
4040

4141
### 파이썬과 mlagents 패키지 설치
4242

43-
ML-Agents toolkit을 사용하기 위해 [setup.py file](../ml-agents/setup.py)에 나열된 종속성과 함께 파이썬 3.10이 필요합니다.
43+
ML-Agents toolkit을 사용하기 위해 [setup.py file](../ml-agents/setup.py)에 나열된 종속성과 함께 파이썬 3.10.12이 필요합니다.
4444
주요 종속성의 일부는 다음을 포함합니다:
4545

4646
- [TensorFlow](Background-TensorFlow.md) (Requires a CPU w/ AVX support)
4747
- [Jupyter](Background-Jupyter.md)
4848

49-
Python 3.10이 만약 설치되어 있지 않다면, [다운로드](https://www.python.org/downloads/)하고 설치하십시오.
49+
Python 3.10.12이 만약 설치되어 있지 않다면, [다운로드](https://www.python.org/downloads/)하고 설치하십시오.
5050

5151
만약 당신의 파이썬 환경이 `pip3`을 포함하지 않는다면, 다음
5252
[지시사항](https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers)
@@ -64,7 +64,7 @@ pip3 install mlagents
6464

6565
**주의:**
6666

67-
- 현재 Python 3.10 또는 Python 3.5을 지원하지 않습니다.
67+
- 현재 Python 3.10.12 또는 Python 3.5을 지원하지 않습니다.
6868
- 만약 Anaconda를 사용하고 TensorFlow에 문제가 있다면, 다음
6969
[링크](https://www.tensorflow.org/install/pip)에서 Anaconda 환경에서 어떻게 TensorFlow를 설치하는지 확인하십시오.
7070
### 개발을 위한 설치방법

localized_docs/RU/docs/Установка.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ML-Agents Toolkit состоит из нескольких компоненто
3333

3434
### Установка **Python 3.10.12** или более поздней версии
3535

36-
Мы рекомендуем [установить](https://www.python.org/downloads/) Python 3.10.
36+
Мы рекомендуем [установить](https://www.python.org/downloads/) Python 3.10.12
3737
Если вы используете Windows, пожалуйста, установите x86-64 версию, а не x86.
3838
Если у вас нет системы управления пакетами `pip3` для Python, пожалуйста,
3939
воспользуйтесь [этими инструкциями](https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers)

localized_docs/TR/docs/Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ML-Agents Toolkit 'i kurmanız için gerekenler:
2727

2828
### **Python 3.10.12** veya Daha Yüksek Bir Sürüm Yükleyin
2929

30-
Python 3.10 veya daha yüksek bir sürümü [yüklemenizi](https://www.python.org/downloads/) öneriyoruz. Eğer, Windows kullanıyorsanız, lütfen x86-64 versiyonunu kurun ve asla sadece x86 isimli versiyonu kurmayın. Python ortamınız `pip3` içermiyorsa, [talimatları](https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers) takip ederek yükleyebilirsiniz.
30+
Python 3.10.12 veya daha yüksek bir sürümü [yüklemenizi](https://www.python.org/downloads/) öneriyoruz. Eğer, Windows kullanıyorsanız, lütfen x86-64 versiyonunu kurun ve asla sadece x86 isimli versiyonu kurmayın. Python ortamınız `pip3` içermiyorsa, [talimatları](https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers) takip ederek yükleyebilirsiniz.
3131

3232
Windows'ta Anaconda kurulumu için destek sağlamıyor olsak da,
3333
önceki [Windows için Anaconda Yüklemesi (Kullanımdan Kaldırılan) Rehberine](Installation-Anaconda-Windows.md) bakabilirsiniz.

ml-agents-envs/mlagents_envs/environment.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def __init__(
149149
base_port: Optional[int] = None,
150150
seed: int = 0,
151151
no_graphics: bool = False,
152+
no_graphics_monitor: bool = False,
152153
timeout_wait: int = 60,
153154
additional_args: Optional[List[str]] = None,
154155
side_channels: Optional[List[SideChannel]] = None,
@@ -160,19 +161,18 @@ def __init__(
160161
Notice: Currently communication between Unity and Python takes place over an open socket without authentication.
161162
Ensure that the network where training takes place is secure.
162163
163-
:string file_name: Name of Unity environment binary.
164-
:int base_port: Baseline port number to connect to Unity environment over. worker_id increments over this.
165-
If no environment is specified (i.e. file_name is None), the DEFAULT_EDITOR_PORT will be used.
166-
:int worker_id: Offset from base_port. Used for training multiple environments simultaneously.
167-
:bool no_graphics: Whether to run the Unity simulator in no-graphics mode
168-
:int timeout_wait: Time (in seconds) to wait for connection from environment.
169-
:list args: Addition Unity command line arguments
170-
:list side_channels: Additional side channel for no-rl communication with Unity
171-
:str log_folder: Optional folder to write the Unity Player log file into. Requires absolute path.
164+
:string file_name: Name of Unity environment binary. :int base_port: Baseline port number to connect to Unity
165+
environment over. worker_id increments over this. If no environment is specified (i.e. file_name is None),
166+
the DEFAULT_EDITOR_PORT will be used. :int worker_id: Offset from base_port. Used for training multiple
167+
environments simultaneously. :bool no_graphics: Whether to run the Unity simulator in no-graphics mode :bool
168+
no_graphics_monitor: Whether to run the main worker in graphics mode, with the remaining in no-graphics mode
169+
:int timeout_wait: Time (in seconds) to wait for connection from environment. :list args: Addition Unity
170+
command line arguments :list side_channels: Additional side channel for no-rl communication with Unity :str
171+
log_folder: Optional folder to write the Unity Player log file into. Requires absolute path.
172172
"""
173173
atexit.register(self._close)
174174
self._additional_args = additional_args or []
175-
self._no_graphics = no_graphics
175+
self._no_graphics = no_graphics or no_graphics_monitor and worker_id != 0
176176
# If base port is not specified, use BASE_ENVIRONMENT_PORT if we have
177177
# an environment, otherwise DEFAULT_EDITOR_PORT
178178
if base_port is None:

ml-agents/mlagents/trainers/cli_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ def _create_parser() -> argparse.ArgumentParser:
297297
"the graphics driver. Use this only if your agents don't use visual observations.",
298298
)
299299

300+
eng_conf.add_argument(
301+
"--no-graphics-monitor",
302+
default=False,
303+
action=DetectDefaultStoreTrue,
304+
help="Whether to run the main Unity worker in graphics mode with the remaining workers in no graphics mode"
305+
"(i.e. without initializing the graphics driver. Use this only if your agents don't use visual "
306+
"observations.",
307+
)
308+
300309
torch_conf = argparser.add_argument_group(title="Torch Configuration")
301310
torch_conf.add_argument(
302311
"--torch-device",

0 commit comments

Comments
 (0)