I have always had a question about mlagents: they randomly select actions at the beginning of training. Can we incorporate human intervention into the training process of mlagents to make them train faster? Is there a corresponding method in mlagents? Looking forward to your answer.
Thanks for the little introduction. It was very stupid to get all the right versions done but at the end it works and ill try out some stuff for my own projects :)
maybe you wont notice this comment,but i have to persist to say thank you bro,i successfully configured my mlagents env,but unfortunately due to new edition of unity or something else,i cant address all the errors mentioned in the console,but yeah,thank you again!
As of 2nd April, 2023, if anybody's getting PROTOBUF error or something like this while trying to train mlagents, run the command with environment activated "pip install protobuf==3.19.6"
TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class. i am getting this error
I am using 2021.3.22f1 and I am getting The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
Thanks for this great tutorial. Minor detail, if it's the first time, you may have an error "Module onnx is not installed!". Just resolve it with : pip3 install onnx
Thank you for this aamazing video, really enjoy to follow. I already follow the instruction. However, I face a problem. When I start training the agent, the folder summaries cannot generated, so that I cannot move to visualize the result using tensorboard. Is there any steps I missing? Thank you.
Thank you very much. Great video. You helped me a lot. Only problem was with current numpy version, so I had to downgrade it to 1.23.3 but everything else is up to date.
Gracias bro... aunque antes había hecho varias preguntas, paso a paso las fui resolviendo, desde hace rato quería aprender a y utilizar MLAgent, pero siempre había un problema, pero este video me ayudo de muchas gracias, espero en un futuro puedas dar ejemplos haciendo proyectos desde 0. Un gran abrazo
@@PhilippDominicSiedler ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zPFU30tbyKs.html the tutorial is "how to use ml agents in unity" by code monkey
@@mikhailhumphries Right, so code monkey is using venv, I'm using conda through Anaconda. When installing Anaconda, as explained in the video, python 3.9 is automatically installed, not sure if that is the same for venv.
We need to load models that we download in runtime from a webserver, and we execute it in a build (not in Editor), is it possible? All the examples and code I find only work within Editor using the Resources Folder and the walk scene only works in the editor and we i try to build it, it reverts back to the default ONNX Model.
when I add mlagent example asset to unity it said " The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" how to fix it?
@@PhilippDominicSiedler so .I start at open package manager and add these link "com.unity.nuget.newtonsoft-json@3.0" after click add package from git url, that's it
you need to be in the ml-agents folder directory as I have been showing and then use this command: tensorboard --logdir=results, there will be a URL that you can open in your browser
Be very observant on what version you have on everything you install. It does not always install the exact version you expect it to. My "file version" in the explorer(win) of python exe is 3.10.8150.1013 im not sure if this was the source of the problem but if the "file version" is an expression of the exact version of the program then 3.10.8150.1013 i just above the limit of an acceptable python versions for the mlagent package i think. I installed python 3.8 (.16) and it finally could build wheel with gym .toml files. the numPy version was 1.14.1 which just came automatically when i created a new conda environment with python 3.8.
Hello I am getting an error while doing pip3 install -e ./ml-agents-envs note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for numpy Failed to build numpy ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
@@insertedfailed3586 at 7:00 on the right side you can see the config files that exist, we are using PushBlock.yaml in there you can find a parameter that is called "max_steps", should be all the way at the bottom. Let me know if that helps.
If i wanna start it with "mlagents-learn config/ppo/PushBlock.yaml --run-id=push_block_test_01" this Message came ever "The "mlagents-learn" command is either misspelled or could not be found." I need help
I am getting error too.OTL (mlagents_r19_YT) C:\Users\aron1\OneDrive\바탕 화면\ml-agents-release_19_YT\ml-agents-release_19>mlagents-learn config\ppo\PushBlock.yaml --run-id=push_block_test_01 Traceback (most recent call last): File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib unpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib unpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\Scripts\mlagents-learn.exe\__main__.py", line 4, in File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\mlagents\trainers\learn.py", line 2, in from mlagents import torch_utils File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in from mlagents.torch_utils.torch import torch as torch # noqa File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in from mlagents.trainers.settings import TorchSettings File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\mlagents\trainers\settings.py", line 626, in class TrainerSettings(ExportableSettings): File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\mlagents\trainers\settings.py", line 649, in TrainerSettings cattr.register_structure_hook( File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\cattr\converters.py", line 269, in register_structure_hook self._structure_func.register_cls_list([(cl, func)]) File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\lib\site-packages\cattr\dispatch.py", line 57, in register_cls_list self._single_dispatch.register(cls, handler) File "C:\Users\aron1\anaconda3\envs\mlagents_r19_YT\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.
@everyone !!very important!! date: 11 may 2023 you need to downgrade protobuf and numby. commands: pip install protobuf==3.19.6 pip install numby ==1.21.5 EDIT: I have one question: which onnx version do you use. when the training is finished It's a bit much and in german but further it said that i need a newer onnx version and then this happened [INFO] PushBlock. Step: 240000. Time Elapsed: 219.684 s. Mean Reward: 4.848. Std of Reward: 0.804. Training. [WARNING] Restarting worker[0] after 'Communicator has exited.' [INFO] Listening on port 5004. Start training by pressing the Play button in the Unity Editor. ============= Diagnostic Run torch.onnx.export version 2.0.1+cu118 ============= verbose: False, log level: Level.ERROR ======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ======================== [INFO] Exported results\push_block_test02\PushBlock\PushBlock-279713.onnx [INFO] Copied results\push_block_test02\PushBlock\PushBlock-279713.onnx to results\push_block_test02\PushBlock.onnx. Traceback (most recent call last): File "C:\Users\samue\anaconda3\envs\mlagents_R19\Scripts\mlagents-learn-script.py", line 33, in sys.exit(load_entry_point('mlagents', 'console_scripts', 'mlagents-learn')()) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 260, in main run_cli(parse_command_line()) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 256, in run_cli run_training(run_seed, options, num_areas) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 132, in run_training tc.start_learning(env_manager) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents-envs\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\trainer_controller.py", line 176, in start_learning n_steps = self.advance(env_manager) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents-envs\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\trainer_controller.py", line 234, in advance new_step_infos = env_manager.get_steps() File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\env_manager.py", line 124, in get_steps new_step_infos = self._step() File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 420, in _step self._restart_failed_workers(step) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 328, in _restart_failed_workers self.reset(self.env_parameters) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\env_manager.py", line 68, in reset self.first_step_infos = self._reset_env(config) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 446, in _reset_env ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {}) File "c:\users\samue\desktop\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 101, in recv raise env_exception mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that : The environment does not need user interaction to launch The Agents' Behavior Parameters > Behavior Type is set to "Default" The environment and the Python interface have compatible versions. If you're running on a headless server without graphics support, turn off display by either passing --no-graphics option or build your Unity executable as server build.
*Hi, everything seems to be working as intended, thank you, I haven't started training yet, but after testing, right after it tells me results have been exported and copied I get the following traceback:* Traceback (most recent call last): File "C:\Users\Rabiie\.conda\envs\mlagents_r19_YT\Scripts\mlagents-learn-script.py", line 33, in sys.exit(load_entry_point('mlagents', 'console_scripts', 'mlagents-learn')()) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 260, in main run_cli(parse_command_line()) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 256, in run_cli run_training(run_seed, options, num_areas) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\learn.py", line 132, in run_training tc.start_learning(env_manager) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents-envs\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\trainer_controller.py", line 176, in start_learning n_steps = self.advance(env_manager) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents-envs\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\trainer_controller.py", line 234, in advance new_step_infos = env_manager.get_steps() File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\env_manager.py", line 124, in get_steps new_step_infos = self._step() File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 420, in _step self._restart_failed_workers(step) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 328, in _restart_failed_workers self.reset(self.env_parameters) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\env_manager.py", line 68, in reset self.first_step_infos = self._reset_env(config) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 446, in _reset_env ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {}) File "c:\users\Riser\desktop\ml-agents-release_19\ml-agents-release_19\ml-agents\mlagents\trainers\subprocess_env_manager.py", line 101, in recv raise env_exception mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that : The environment does not need user interaction to launch The Agents' Behavior Parameters > Behavior Type is set to "Default" The environment and the Python interface have compatible versions. If you're running on a headless server without graphics support, turn off display by either passing --no-graphics option or build your Unity executable as server build. *This doesn't appear in your video, should I be worried?* *EDIT: I feel I should add I start learning by typing: **_"mlagents-learn --force"_** as I'm not using a Unity example in an empty project, but already have a project set up that I integrated MLAgents to.*
@@PhilippDominicSiedler It is, I have a single agent and a training environment inside a prefab, I have a script that instantiates 10 of it on the scene inside the Awake() function. So is there an issue? Or is that traceback just there for information?
@@THExRISER ah yeah, that’s a difficult one, so the way I did that in the past is instantiate them with their parent gameObject disabled, and once all agents are instantiated set them enabled
@@PhilippDominicSiedler TLDR; The traceback only appears if MLAgents listens in but the training never starts, how do I interrupt training from Anaconda? While I'm at it? Should I be worried about that UserWarning we're both getting? Or is that just performance related? *Long Version:* I believe you mean SetActive, ok, I did that, no difference, traceback is still there, but I found something odd: I interrupt training by hitting the play button on Unity (because I don't know how else to do that and CTR-C only works when it's listening and not training), when I do I get the following: ** [WARNING] Restarting worker[0] after 'Communicator has exited.' [INFO] Listening on port 5004. Start training by pressing the Play button in the Unity Editor. ** It tries to listen for a bit longer before exporting and copying results, if I do hit CTRL-C while it's listening in, the traceback doesn't appear after copying and exporting results, if I don't do anything and wait instead, it does. I think the problem may be in the way I'm interrupting training, I saw/heard you hit some keys in the video to interrupt training, without touching the unity interface, from what I can find it's supposed to be CTRL-C but it doesn't work for me during training, only when it's listening, odd.