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

Issues installing #5912

Closed tntisthebomb closed 1 year ago

tntisthebomb commented 1 year ago

I've done pretty much everything that the internet says to fix these errors after pip3 installing the mlagents package, It tells me that everything was already met (requirement wise) but Then hands me this error after running mlagents-learn --help. I used most python versions and am using 3.9.12 currently, Here's the error:

Requirement already satisfied: mlagents in c:\users\user\anaconda3\lib\site-packages (0.28.0) Requirement already satisfied: grpcio>=1.11.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.54.0) Requirement already satisfied: h5py>=2.9.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (3.7.0) Requirement already satisfied: mlagents-envs==0.28.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (0.28.0) Requirement already satisfied: numpy<2.0,>=1.13.3 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.23.5) Requirement already satisfied: Pillow>=4.2.1 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (9.4.0) Requirement already satisfied: protobuf>=3.6 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (3.20.0) Requirement already satisfied: pyyaml>=3.1.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (6.0) Requirement already satisfied: tensorboard>=1.15 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (2.12.2) Requirement already satisfied: attrs>=19.3.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (22.1.0) Requirement already satisfied: pypiwin32==223 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (223) Requirement already satisfied: cattrs<1.7,>=1.1.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.5.0) Requirement already satisfied: cloudpickle in c:\users\user\anaconda3\lib\site-packages (from mlagents-envs==0.28.0->mlagents) (2.0.0) Requirement already satisfied: pywin32>=223 in c:\users\user\anaconda3\lib\site-packages (from pypiwin32==223->mlagents) (305.1) Requirement already satisfied: absl-py>=0.4 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.4.0) Requirement already satisfied: google-auth<3,>=1.6.3 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.17.3) Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.0.0) Requirement already satisfied: markdown>=2.6.8 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (3.4.1) Requirement already satisfied: requests<3,>=2.21.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.28.1) Requirement already satisfied: setuptools>=41.0.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (65.6.3) Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (0.7.0) Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.8.1) Requirement already satisfied: werkzeug>=1.0.1 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.2.2) Requirement already satisfied: wheel>=0.26 in c:\users\user\appdata\roaming\python\python310\site-packages (from tensorboard>=1.15->mlagents) (0.37.1) Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (5.3.0) Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (0.2.8) Requirement already satisfied: six>=1.9.0 in c:\users\user\appdata\roaming\python\python310\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (1.16.0) Requirement already satisfied: rsa<5,>=3.1.4 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (4.9) Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\user\anaconda3\lib\site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard>=1.15->mlagents) (1.3.1) Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (3.4) Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (1.26.14) Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (2022.12.7) Requirement already satisfied: MarkupSafe>=2.1.1 in c:\users\user\anaconda3\lib\site-packages (from werkzeug>=1.0.1->tensorboard>=1.15->mlagents) (2.1.1) Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\users\user\anaconda3\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (0.4.8) Requirement already satisfied: oauthlib>=3.0.0 in c:\users\user\anaconda3\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard>=1.15->mlagents) (3.2.2) C:\Users\User>mlagents-learn --help Traceback (most recent call last): File "C:\Users\User\anaconda3\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\User\anaconda3\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\User\anaconda3\Scripts\mlagents-learn.exe__main.py", line 4, in File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\learn.py", line 2, in from mlagents import torch_utils File "C:\Users\User\anaconda3\lib\site-packages\mlagents\torch_utils\init__.py", line 1, in from mlagents.torch_utils.torch import torch as torch # noqa File "C:\Users\User\anaconda3\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in from mlagents.trainers.settings import TorchSettings File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\settings.py", line 644, in class TrainerSettings(ExportableSettings): File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings cattr.register_structure_hook( File "C:\Users\User\anaconda3\lib\site-packages\cattr\converters.py", line 207, in register_structure_hook self._structure_func.register_cls_list([(cl, func)]) File "C:\Users\User\anaconda3\lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list self._single_dispatch.register(cls, handler) File "C:\Users\User\anaconda3\lib\functools.py", line 856, in register raise TypeError( TypeError: Invalid first argument to register(). typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class.

tntisthebomb commented 1 year ago

I fixed it by downgrading python, but another issue has risen: E:\mlgame\ml-agents-release_20\Project\Assets>mlagents-learn config/trainer_config.yaml --run-id=test Traceback (most recent call last): File "c:\users\user\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\user\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\User\AppData\Local\Programs\Python\Python37\Scripts\mlagents-learn.exe__main__.py", line 7, in File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mlagents\trainers\learn.py", line 260, in main run_cli(parse_command_line()) File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mlagents\trainers\learn.py", line 52, in parse_command_line return RunOptions.from_argparse(args) File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mlagents\trainers\settings.py", line 931, in from_argparse key mlagents.trainers.exception.TrainerConfigError: The option default was specified in your YAML file, but is invalid.

AzizRourou commented 1 year ago

Is "trainer_config.yaml" a provided file or a custom file?

miguelalonsojr commented 1 year ago

Are you installing from source or from pypi?

hdeavila1992 commented 1 year ago

ERROR: Ignored the following versions that require a different python version: 0.10.0.dev0 Requires-Python >=3.6,<3.7;

I have Python 3.11.1 So I Have to downgrade python too?

Draco18s commented 1 year ago

Are you installing from source or from pypi?

Just ran into the original issue myself using Python 3.9.13 I saw that one of the dependencies required Python 3.8 to 3.10 and so I went with 3.9 as the subversions weren't directly accessible from the windows store, so it was the only quick-easy version I could install that matched the known requirements.

As for how I'm installing it; pypi.

PS C:\> mlagents-learn config/pewpew_config.yaml --run-id=PewPew
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.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.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module>
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mlagents\trainers\learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mlagents\torch_utils\torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mlagents\trainers\settings.py", line 625, in <module>
    class TrainerSettings(ExportableSettings):
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mlagents\trainers\settings.py", line 648, in TrainerSettings
    cattr.register_structure_hook(
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cattr\converters.py", line 207, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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.3568.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.
PS C:\U> python --version
Python 3.9.13
PS C:\>

In addition, the docs don't indicate the correct way to point mlagents-learn at the config file; it just says you can "run the command from anywhere" and doesn't indicate exactly where the config file is supposed to go: image image

Not that specifying a full path helps. I will be downgrading python next.

Draco18s commented 1 year ago

Downgrading to Python 3.8.10 was sufficient to get things working, but I did run into one further error that required manually fixing something (in this case one line of one py file).

  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mlagents\trainers\buffer.py", line 211, in AgentBufferField
    self, pad_value: np.float = 0, dtype: np.dtype = np.float32
  File "C:\Users\draco\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

All I had to do was change line 211 in buffer.py to float instead of np.float

And that let it try and load a config file, which solved the directory issue.

> mlagents-learn config/pewpew_config.yaml --run-id=PewPew
> TrainerConfigError: Config file could not be found at C:\Users\draco\Documents\Unity Projects\pewpew\Assets\config\config\pewpew_config.yaml

Apparently the full path is interpreted from my current directory, so the "run from anywhere" isn't really true.