Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.12k stars 4.15k forks source link

Python 3.9.10 causes mlagents-learn not to work #5689

Closed jimlbeaver closed 2 years ago

jimlbeaver commented 2 years ago

using mlagents-learn on python 3.9.10 on windows causes the following error: "TypeError: Invalid first argument to register(). typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class."

reported here: https://forum.unity.com/threads/cant-train-3dball-or-anything-else.1228128/

From release notes of 3.9.10: bpo-46032: The registry() method of functools.singledispatch() functions checks now the first argument or the first parameter annotation and raises a TypeError if it is not supported. Previously unsupported “types” were ignored (e.g. typing.List[int]) or caused an error at calling time (e.g. list[int]).

bug tracker from python: https://bugs.python.org/issue46032

Environment (please complete the following information):

jimlbeaver commented 2 years ago

call stack:

Python: 3.9.10 Torch: 1.7.1+cu110

Is there anyone that have an idea of what's going on?

(env) C:\Exjobb\ml-agents\ml-agents-main>mlagents-learn config/ppo/3DBall.yaml --run-id=fi

Traceback (most recent call last):

File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

File "C:\Exjobb\unity\env\Scripts\mlagents-learn.exe__main__.py", line 4, in

File "C:\Exjobb\unity\env\lib\site-packages\mlagents\trainers\learn.py", line 2, in

from mlagents import torch_utils

File "C:\Exjobb\unity\env\lib\site-packages\mlagents\torch_utils__init__.py", line 1, in

from mlagents.torch_utils.torch import torch as torch  # noqa

File "C:\Exjobb\unity\env\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in

from mlagents.trainers.settings import TorchSettings

File "C:\Exjobb\unity\env\lib\site-packages\mlagents\trainers\settings.py", line 644, in

class TrainerSettings(ExportableSettings):

File "C:\Exjobb\unity\env\lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings

cattr.register_structure_hook(

File "C:\Exjobb\unity\env\lib\site-packages\cattr\converters.py", line 207, in register_structure_hook

self._structure_func.register_cls_list([(cl, func)])

File "C:\Exjobb\unity\env\lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list

self._single_dispatch.register(cls, handler)

File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\functools.py", line 855, in register

raise TypeError(

TypeError: Invalid first argument to register(). typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class.

maryamhonari commented 2 years ago

Hi jimlbeaver,

Thanks for bringing up this issue. Python 3.9.10 is fairly new and while we're looking into it, I suggest installing with an older version of python if possible.

jimlbeaver commented 2 years ago

I did … 3.9.9 works fine

Thanks for looking in to it and for supporting the product

On Jan 24, 2022, at 9:01 AM, Maryam Honari @.***> wrote:



Hi jimlbeaver https://github.com/jimlbeaver,

Thanks for bringing up this issue. Python 3.9.10 is fairly new and while we're looking into it, I suggest installing with an older version of python if possible.

— Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/ml-agents/issues/5689#issuecomment-1020326327, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6DOWCXCM7Y2EVGI5XMUF3UXWAX5ANCNFSM5MSGHTWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ignace-shoeib commented 2 years ago

this also happens in python 3.10.2

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity in the last 28 days. It will be closed in the next 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed because it has not had activity in the last 42 days. If this issue is still valid, please ping a maintainer. Thank you for your contributions.

maryamhonari commented 2 years ago

new python version mlagents==0.29.0 and mlagents_env==0.29.0 should fix this issue.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.