Hey. First of all, great tutorial. I was hoping you could help with a error i've been seeing a lot in the comments. I was getting this error :""ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects"", so i tried to use your "requirements.txt" file and install the packages with the "correct" versions you specified. I couldn't help but notice the same error when typing "pip install - r requirements.txt" in cmd. I am using python 3.10.0, I also updated pip to the latest version, but i keep getting this error : RuntimeError: Broken toolchain: cannot link a simple C program [end of output] 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: ERROR: Failed to build installable wheels for some pyproject.toml based projects (numpy)" Could it be some C++ tools i didnt install (yes i did download the vs build tools for C++, v:14.0) Also i was wondering if i can follow an outdated tutorial (say CodeMonkey's tutorial for example) and use older versions of torch, python, mlagents etc... Would it theoreticaly work ?
This has been bothering me for a while too. It's upsetting because I cannot reproduce this behavior. You don't need any C++ tools because pip builds the binary version of numpy. If you want to manually install it from source code, then you would need C++, but I have never done that. One thing I can suggest, is running this *pip install --no-cache-dir setuptools wheel* This installs *steuptools* and *wheel* libraries. Try installing numpy after that (make sure you are still in the venv). Not sure if it will fix you issue, but its worth a shot As for following another tutorial, you definitely can try. However, I made this tutorial because following them came with a lot of headaches such as conflicting library versions, outdated python versions, etc. Most tutorials cover the same thing anyway. If you find a solution, please let me know about it so I can pin the comment!
@@pingcode I tried installing the setuptools and wheel libraries as you suggested, but it didn't work. The good news is that I found a comment on CodeMonkey's video suggesting a similar procedure with different versions of Python and the Unity editor. It worked for me, and the "mlagents-learn --help" command worked just fine. I'll juste paste the comment right here : " Hi from 2023! I had some trouble instaling the python enviroment but I made it work. Unity: 2022.3.14f1 Python 3.9.13 Before venv: py -3.9 -m venv venv After venv: python -m pip install --upgrade pip pip install mlagents pip3 install torch torchvision torchaudio pip install protobuf==3.20.3 pip install packaging Works fine! Hope so u too :D " I started from scratch, created a new project with the suggested Unity version, and it worked. #### Another question: Does it matter if I install the ML Agents package (from the Unity editor) after the whole CMD procedure? Will it impact my simulations? Thank you for the quick response btw.
@@IsmaiArrouchdi No it shouldnt make a difference. You might have to restart Unity or CMD if it doesn't detect its been installed yet. But that's it. So looks like using a different python version helped you, that's good to know. I will pint the comment for others to look at. Thanks!
This is the best tutorial on installing ML Agents atm. I followed some other tutorials and documentation but got frustrated after trying so many different versions and nothing worked. This video will get everything working, so thanks a lot!
Thank you very much. I saw Code Monkey's videos and thought it's gonna be perfect, but the installation was weird, so I started looking and your vid is perfect for filling that gap.
I was hoping you could help as I get the error: TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type. I am using 3.11.9 but i have tried python 3.10 and get the same error and help would be greatly appreciated
Are you working in a venv? Is pip up to date? Did you install packages when using python version 3.10.0 and not just switching python versions? If yes to all then I really don't know. I made a dropbox link to my requirements.txt file if you want to try install everything using that? www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=vdsaergu&dl=0 Delete venv folder, and remake it. Put the file in the venv folder. Activate the venv and run *pip install -r requirements.txt*
thank you for the tutorial but can you please help im getting the error OSError: [WinError 127] The specified procedure could not be found. im unsure of what to do
Heyy! thanks for the tutorial, it worked perfectly. But I have a question like in the monkeycode video or any other youtube video about trying out the mlagents, they used agent assets. How would i get the assets? I've downloaded the latest mlagent released which was vers 21 and i dragged the Assets from that folder to mine, but there is an issue which was "The associated script can not be loaded" How would i fix this?
Honestly no idea since I never used the agent asset. I'm assuming you mean the little blue character? I've never used it so I don't know. If that's not what you mean, can you be a bit more specific
@@pingcode yeah it was and actually i resolved it by just using the latest mlagent version tar.gz and extract it and used its Project folder to access the assets properly (including the steps you shown in this vid)
i got this error when i did mlagents-learn --help ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there. i dont understand it
It's hard to say without knowing what you did. The error message is saying that you are trying to import numpy from its source directory. You might have done something wrong when changing directories in the terminal or you might have numpy installed in a weird way on your machine. Is there any part of the tutorial that you are confused about and need help with?
Is it possible to train on GPU with mlagents? In the official documentation I found "Currently for the ML-Agents Toolkit, only CUDA v9.0 and cuDNN v7.0.5 is supported." It is sad, because I can't even install CUDA v9.0 anymore, because it is not compatible with never GPUs :(
I am not sure, I never tried it. Please look at these links, they might be helpful in some way. forum.unity.com/threads/gpu-training-using-ml-agents-cuda-cudnn.910652/ www.tensorflow.org/install/pip github.com/miyamotok0105/unity-ml-agents/blob/master/docs/Installation-Windows.md www.reddit.com/r/Unity2D/comments/16nko4k/how_to_utilize_cuda_during_the_training_of/
Edit: my comments do show up unless you sort by newest first idk why i always get this error message when installing mlagents in python : "ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects" I already tried installing numpy by itself but it was already there could someone please help me?
Did you make a virtual environment? If not, you might be using a version of numpy already installed on your pc. If you did make a virtual environment, try to unistall numpy and reinstall it from within it The error might be indicating a version of numpy not compatible with the current version of python or mlagents.
@@pingcode got the same error when trying to install numpy 1.21.2 on the newest version it just doesnt even tries to create that "wheel" yes i am in an virtual environment heres an List of all the installed packages(if it helps): Package Version ----------------- --------- filelock 3.15.1 fsspec 2024.6.0 intel-openmp 2021.4.0 Jinja2 3.1.4 MarkupSafe 2.1.5 mkl 2021.4.0 mpmath 1.3.0 networkx 3.3 numpy 1.26.4 pillow 10.3.0 pip 24.0 setuptools 57.4.0 sympy 1.12.1 tbb 2021.12.0 torch 2.3.1 torchaudio 2.3.1 torchvision 0.18.1 typing_extensions 4.12.2
@@Phoenix_3223 Thanks for that. Upon checking my pip install list, I see I have a lot more packages installed. Please check this link to download my requirements.txt file I just made: www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=nxd615dq&dl=0 You can try uninstall everything in your virtual environment and installing everything in this file using *pip install -r requirements.txt* Let me know if that works!
@@pingcode i did exactly that untill the installing just stopped because of the same error: ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
Hey, when the help command runs I see you also have an error about torch.set_default_tensor_type() being deprecated. I see it still runs with this, but my results aren't showing on tensor board. Could this error be an indication of why? and any idea what the fix would be?
I'm assuming you ran the tensorflow command in the terminal? I can't help you without more information. A common mistake is that a training session didn't finish yet, so no grpah can be made (which is indicated by the number of `steps`). Let me know what you have tried and I'll try to help you. In the meantime, make sure you read this unity-technologies.github.io/ml-agents/Using-Tensorboard/
@KhaledHossamShosha do you have an nvidia gpu? Cuda is just used to speed up training to my understanding. I don't know much about it. You don't NEED it
I've reveived an error when tried "pip install mlagents": error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [21 lines of output]
sorry, I don't know what could cause this error. Have you tried upgrading pip? Are you using python 3.10.0? Can you share the 21 lines of output that show the error?
@KhaledHossamShosha if you are installing mlagents and you are getting errors saying that you need them, then yes. Since you aren't installing these globally, you would have to do it for every project
There are a lot of different libraries that need to work together in order to have ml agents run properly. Many of these libraries have version conflicts with different python versions. 3.10.0 is a version I found to be stable. 3.12 for example is a newer python version that ml agents doesn't support yet.
Hi, thank you for your simple and short tutorial. I got the error for "protobuf". After installing it, when I execute again mlagents-learn --help, i got the following error : TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type. Can you help me please ?
I had 2 versions of python installed on my computer. I needed to uninstall my recent version of Python to switch on the 3.10 version. I hope it helps someone ;)
Yes, from my experience 3.10.12 is the latest version that works. This is odd because their documentation says 3.10.12 *or higher* unity-technologies.github.io/ml-agents/Installation/ If you don't want to get rid of your current python version, you can install python 3.10.0 and switch the version of python you use in the terminal when running the commands shown in the video
I don't know if someone will see this because it was posted 4 moths ago but I have this error that says TypeError: Invalid first argument to `register()` And I'm confused because when try and find a fix everything says 3.10.0 is'nt copatable with mlagents?
@iaxsgames6029 Are you working in a venv? Is pip up to date? Did you install packages when using python version 3.10.0 and not just switching python versions? If yes to all then I really don't know. I made a dropbox link to my requirements.txt file if you want to try install everything using that? www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=vdsaergu&dl=0 Delete venv folder, and remake it. Put the file in the venv folder. Activate the venv and run *pip install -r requirements.txt*
@@pingcode Do You Know How To Increase max_steps because right now when I say Mlagents-learn --run-id=**** It always pops up at the bottom max_steps: 50000 So It alwasy ends early
@@iaxsgames6029 you have to edit a YAML configuration file somewhere within the files. Please watch a tutorial on using ML-Agents for that. Code monkey's tutorial talk about it!
If you are interested in one on one tutoring for beginner's/intermediate's, I offer it for a fair price. Email me: (mypingo7 [at] yahoo [dot] com) if you are interested!
i get this error at the end: TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.
i am getting the following error when i'm trying to run "pip install nlagents": ERROR: Failed building wheel for numpy Failed to build numpy ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (numpy)
Many people are having this issue and the reason isn't quite clear. The most I found online about this issue is that Numpy and Python are conflicting with each other. Try to install a different version of numpy. Make sure pip is updated. Make sure you are using Python 3.10.0 in the terminal.
@@pingcode that's probably the problem because when i try to install numpy i'm getting this error (and i'm using python 3.10 and pip is updated): (venv) C:\Users\yonat\ot>pip install numpy==1.19 Collecting numpy==1.19 Using cached numpy-1.19.0.zip (7.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [90 lines of output] Running from numpy source directory. :460: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py:73: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. required_version = LooseVersion('0.29.14') C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cython_version) < required_version: performance hint: _common.pyx:275:19: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. performance hint: _common.pyx:299:19: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. performance hint: _common.pyx:322:50: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. performance hint: _common.pyx:1002:32: Exception check after calling 'f1' will always require the GIL to be acquired. Declare 'f1' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. performance hint: _generator.pyx:706:41: Exception check after calling '_shuffle_int' will always require the GIL to be acquired. Possible solutions: 1. Declare '_shuffle_int' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. 2. Use an 'int' return type on '_shuffle_int' to allow an error code to be returned. performance hint: _generator.pyx:735:45: Exception check after calling '_shuffle_int' will always require the GIL to be acquired. Possible solutions: 1. Declare '_shuffle_int' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. 2. Use an 'int' return type on '_shuffle_int' to allow an error code to be returned. Error compiling Cython file: ------------------------------------------------------------ ... for i in range(1, RK_STATE_LEN): self.rng_state.key[i] = val[i] self.rng_state.pos = i self._bitgen.state = &self.rng_state self._bitgen.next_uint64 = &mt19937_uint64 ^ ------------------------------------------------------------ _mt19937.pyx:138:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to the type of the value being assigned. Processing numpy/random\_bounded_integers.pxd.in Processing numpy/random\bit_generator.pyx Processing numpy/random\mtrand.pyx Processing numpy/random\_bounded_integers.pyx.in Processing numpy/random\_common.pyx Processing numpy/random\_generator.pyx Processing numpy/random\_mt19937.pyx Traceback (most recent call last): File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 235, in main() File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 231, in main find_process_files(root_dir) File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 222, in find_process_files process(root_dir, fromfile, tofile, function, hash_db) File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 188, in process processor_function(fromfile, tofile) File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 77, in process_pyx subprocess.check_call( File "C:\Users\yonat\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['C:\\Users\\yonat\\ot\\venv\\Scripts\\python.exe', '-m', 'cython', '-3', '--fast-fail', '-o', '_mt19937.c', '_mt19937.pyx']' returned non-zero exit status 1. Cythonizing sources Traceback (most recent call last): File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in main() File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 149, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 368, in prepare_metadata_for_build_wheel self.run_setup() File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 497, in run_setup super().run_setup(setup_script=setup_script) File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 313, in run_setup exec(code, locals()) File "", line 489, in File "", line 469, in setup_package File "", line 274, in generate_cython RuntimeError: Running cythonize failed! [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
apologies for the late reply, if you still have the issue. Do you know what numpy version you have? You might have an older numpy version installed on your PC that isn't compatible with python 3.10 This issue page might be helpful to read what others have said. Someone mentions at the end they used numpy version 1.23.3 and it works github.com/Unity-Technologies/ml-agents/issues/6008
@@pingcode I am running into the same issue. I am using Numpy 1.23.3 and python 3.10.0 and I also get the "ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects" message :/ Help would greatly be appreciated!
@@BastiaanNetjes I'm not sure since I never ran into this issue myself. The only thing I can suggest is to uninstall numpy and reinstall it to see if that fixes anything. To my knowledge, you might also need C++ Build Tools installed since python and some libraries like numpy use C/C++. Though this is speculation. Here is a link to the build tools: visualstudio.microsoft.com/visual-cpp-build-tools/
Can you please help me with these???????? pleaseeeeeeeeeeeeeee (venv) C:\Windows\System32>mlagents-learn --help Traceback (most recent call last): File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib unpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib unpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Windows\System32\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\learn.py", line 2, in from mlagents import torch_utils File "C:\Windows\System32\venv\lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in from mlagents.torch_utils.torch import torch as torch # noqa File "C:\Windows\System32\venv\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in from mlagents.trainers.settings import TorchSettings File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\settings.py", line 25, in from mlagents.trainers.cli_utils import StoreConfigFile, DetectDefault, parser File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\cli_utils.py", line 5, in from mlagents_envs.environment import UnityEnvironment File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs\environment.py", line 48, in from .rpc_communicator import RpcCommunicator File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs pc_communicator.py", line 1, in import grpc File "C:\Windows\System32\venv\lib\site-packages\grpc\__init__.py", line 22, in from grpc import _compression File "C:\Windows\System32\venv\lib\site-packages\grpc\_compression.py", line 20, in from grpc._cython import cygrpc ImportError: cannot import name 'cygrpc' from 'grpc._cython' (C:\Windows\System32\venv\lib\site-packages\grpc\_cython\__init__.py)
Hey. First of all, great tutorial.
I was hoping you could help with a error i've been seeing a lot in the comments. I was getting this error :""ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects"", so i tried to use your "requirements.txt" file and install the packages with the "correct" versions you specified. I couldn't help but notice the same error when typing "pip install - r requirements.txt" in cmd. I am using python 3.10.0, I also updated pip to the latest version, but i keep getting this error :
RuntimeError: Broken toolchain: cannot link a simple C program
[end of output]
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: ERROR: Failed to build installable wheels for some pyproject.toml based projects (numpy)"
Could it be some C++ tools i didnt install (yes i did download the vs build tools for C++, v:14.0)
Also i was wondering if i can follow an outdated tutorial (say CodeMonkey's tutorial for example) and use older versions of torch, python, mlagents etc... Would it theoreticaly work ?
This has been bothering me for a while too. It's upsetting because I cannot reproduce this behavior.
You don't need any C++ tools because pip builds the binary version of numpy. If you want to manually install it from source code, then you would need C++, but I have never done that.
One thing I can suggest, is running this *pip install --no-cache-dir setuptools wheel*
This installs *steuptools* and *wheel* libraries. Try installing numpy after that (make sure you are still in the venv).
Not sure if it will fix you issue, but its worth a shot
As for following another tutorial, you definitely can try. However, I made this tutorial because following them came with a lot of headaches such as conflicting library versions, outdated python versions, etc. Most tutorials cover the same thing anyway.
If you find a solution, please let me know about it so I can pin the comment!
@@pingcode
I tried installing the setuptools and wheel libraries as you suggested, but it didn't work. The good news is that I found a comment on CodeMonkey's video suggesting a similar procedure with different versions of Python and the Unity editor. It worked for me, and the "mlagents-learn --help" command worked just fine. I'll juste paste the comment right here :
" Hi from 2023! I had some trouble instaling the python enviroment but I made it work.
Unity: 2022.3.14f1
Python 3.9.13
Before venv:
py -3.9 -m venv venv
After venv:
python -m pip install --upgrade pip
pip install mlagents
pip3 install torch torchvision torchaudio
pip install protobuf==3.20.3
pip install packaging
Works fine! Hope so u too :D "
I started from scratch, created a new project with the suggested Unity version, and it worked.
#### Another question: Does it matter if I install the ML Agents package (from the Unity editor) after the whole CMD procedure? Will it impact my simulations?
Thank you for the quick response btw.
@@IsmaiArrouchdi No it shouldnt make a difference. You might have to restart Unity or CMD if it doesn't detect its been installed yet. But that's it.
So looks like using a different python version helped you, that's good to know. I will pint the comment for others to look at.
Thanks!
@@IsmaiArrouchdi this was the same solution for me. I guess you need the exact python version for the different version of Ml-agents
@@IsmaiArrouchdi This worked for me too.
I am soo glad somebody is making a update to his older setup!
jezz, finaly tutorial that really helped... i was trying to setup my training for almost a week. you`re life saver
Appreciate it! Good luck with your project
This is the best tutorial on installing ML Agents atm. I followed some other tutorials and documentation but got frustrated after trying so many different versions and nothing worked. This video will get everything working, so thanks a lot!
Glad it helped!
Thank you very much. I saw Code Monkey's videos and thought it's gonna be perfect, but the installation was weird, so I started looking and your vid is perfect for filling that gap.
Glad I could help!
Best. Tutorial. I. Have. Watched. In. My. Life.
Thank you
buddy, thank you soooooo much for this tutorial. it helped me a lot. i was struggling so much with the setup
@tornoa1 anytime! Glad I could help 👍
ILY so much man I was about to give up but you saved me
@@theconductor_real awesome! Great to hear :)
Legend. Got stuck on this for 2.5 hours
I'm so glad it helped!
very much appreciated this video needed to be made!
You're welcome! 😊
Thank you so much! i spent like 5 hours trying to install this and i finally stumbled upon this tutorial
@@snakeywakey4109 glad I could help!
Awesome tutorial. I used your video to setup a shell script so I don't have to remember to do
@@bigedwerd awesome stuff, glad I could help
thank you so much my friend. you save my day!
Thanks. It works like a charm.
@@paulmeynckens6676 awesome 👌
thank you man I finally got it working
@@Zufation awesome!
You're the best!!
Loved the tutorial
Thank you 😊
I was hoping you could help as I get the error: TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.
I am using 3.11.9 but i have tried python 3.10 and get the same error and help would be greatly appreciated
Are you working in a venv?
Is pip up to date?
Did you install packages when using python version 3.10.0 and not just switching python versions?
If yes to all then I really don't know. I made a dropbox link to my requirements.txt file if you want to try install everything using that?
www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=vdsaergu&dl=0
Delete venv folder, and remake it. Put the file in the venv folder. Activate the venv and run *pip install -r requirements.txt*
@@pingcode Thank you this worked you have literally saved my dissertation
@@nicholaspaleologos7088 awesome, glad it worked out!
tqu every much for this
thank you for the tutorial but can you please help im getting the error
OSError: [WinError 127] The specified procedure could not be found.
im unsure of what to do
Thank You so much. You just saved me
Glad I could help!
Heyy! thanks for the tutorial, it worked perfectly. But I have a question like in the monkeycode video or any other youtube video about trying out the mlagents, they used agent assets. How would i get the assets? I've downloaded the latest mlagent released which was vers 21 and i dragged the Assets from that folder to mine, but there is an issue which was "The associated script can not be loaded" How would i fix this?
Honestly no idea since I never used the agent asset. I'm assuming you mean the little blue character? I've never used it so I don't know. If that's not what you mean, can you be a bit more specific
@@pingcode yeah it was and actually i resolved it by just using the latest mlagent version tar.gz and extract it and used its Project folder to access the assets properly (including the steps you shown in this vid)
@potato8938 That's great to hear 👍
i got this error when i did mlagents-learn --help ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there. i dont understand it
It's hard to say without knowing what you did.
The error message is saying that you are trying to import numpy from its source directory. You might have done something wrong when changing directories in the terminal or you might have numpy installed in a weird way on your machine.
Is there any part of the tutorial that you are confused about and need help with?
Thank you!!!🙏
No problem!
Is it possible to train on GPU with mlagents?
In the official documentation I found "Currently for the ML-Agents Toolkit, only CUDA v9.0 and cuDNN v7.0.5 is supported."
It is sad, because I can't even install CUDA v9.0 anymore, because it is not compatible with never GPUs :(
I am not sure, I never tried it.
Please look at these links, they might be helpful in some way.
forum.unity.com/threads/gpu-training-using-ml-agents-cuda-cudnn.910652/
www.tensorflow.org/install/pip
github.com/miyamotok0105/unity-ml-agents/blob/master/docs/Installation-Windows.md
www.reddit.com/r/Unity2D/comments/16nko4k/how_to_utilize_cuda_during_the_training_of/
Edit: my comments do show up unless you sort by newest first idk why
i always get this error message when installing mlagents in python :
"ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects"
I already tried installing numpy by itself but it was already there
could someone please help me?
Did you make a virtual environment? If not, you might be using a version of numpy already installed on your pc.
If you did make a virtual environment, try to unistall numpy and reinstall it from within it
The error might be indicating a version of numpy not compatible with the current version of python or mlagents.
@@pingcode got the same error when trying to install numpy 1.21.2
on the newest version it just doesnt even tries to create that "wheel"
yes i am in an virtual environment
heres an List of all the installed packages(if it helps):
Package Version
----------------- ---------
filelock 3.15.1
fsspec 2024.6.0
intel-openmp 2021.4.0
Jinja2 3.1.4
MarkupSafe 2.1.5
mkl 2021.4.0
mpmath 1.3.0
networkx 3.3
numpy 1.26.4
pillow 10.3.0
pip 24.0
setuptools 57.4.0
sympy 1.12.1
tbb 2021.12.0
torch 2.3.1
torchaudio 2.3.1
torchvision 0.18.1
typing_extensions 4.12.2
@@Phoenix_3223 Thanks for that. Upon checking my pip install list, I see I have a lot more packages installed. Please check this link to download my requirements.txt file I just made: www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=nxd615dq&dl=0
You can try uninstall everything in your virtual environment and installing everything in this file using *pip install -r requirements.txt*
Let me know if that works!
@@pingcode i did exactly that untill the installing just stopped because of the same error: ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
I had this and had the microsoft store version which was 3.10.11 and installing 3.10.0 fixed it
Hey, when the help command runs I see you also have an error about torch.set_default_tensor_type() being deprecated. I see it still runs with this, but my results aren't showing on tensor board. Could this error be an indication of why? and any idea what the fix would be?
I'm assuming you ran the tensorflow command in the terminal? I can't help you without more information. A common mistake is that a training session didn't finish yet, so no grpah can be made (which is indicated by the number of `steps`).
Let me know what you have tried and I'll try to help you.
In the meantime, make sure you read this
unity-technologies.github.io/ml-agents/Using-Tensorboard/
@@pingcode Yes looks like I excited it too early. Thank You
thank you very much it worked thanks
@@KhaledHossamShosha Awesome!
@@pingcode Dose i need a CUDA in this release ?
@KhaledHossamShosha do you have an nvidia gpu?
Cuda is just used to speed up training to my understanding. I don't know much about it. You don't NEED it
@@pingcode i have RTX3050
@@KhaledHossamShosha yeah so then you should be able to use it. Try look up some documentation or videos
here ask for barracuda when install it 999+ errors appears
I've reveived an error when tried "pip install mlagents": error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
sorry, I don't know what could cause this error. Have you tried upgrading pip? Are you using python 3.10.0? Can you share the 21 lines of output that show the error?
Does i need to install pytorch and protobuf in every unity project that i create
@KhaledHossamShosha if you are installing mlagents and you are getting errors saying that you need them, then yes.
Since you aren't installing these globally, you would have to do it for every project
thx
yw
why exactly python 3.10.0 ? I can't use 3.12 fo example ?
There are a lot of different libraries that need to work together in order to have ml agents run properly. Many of these libraries have version conflicts with different python versions.
3.10.0 is a version I found to be stable. 3.12 for example is a newer python version that ml agents doesn't support yet.
Hi, thank you for your simple and short tutorial. I got the error for "protobuf". After installing it, when I execute again mlagents-learn --help, i got the following error : TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type. Can you help me please ?
I had 2 versions of python installed on my computer. I needed to uninstall my recent version of Python to switch on the 3.10 version. I hope it helps someone ;)
@simonnaulet2118 you dont have to uninstall that python version! You can just switch python versions in the terminal when needed.
@@pingcode where terminal
opps nvm
Hey does it only work with python 3.10.0? i have 3.11 and it isnt working
Yes, from my experience 3.10.12 is the latest version that works. This is odd because their documentation says 3.10.12 *or higher*
unity-technologies.github.io/ml-agents/Installation/
If you don't want to get rid of your current python version, you can install python 3.10.0 and switch the version of python you use in the terminal when running the commands shown in the video
Ill give it a try and tell you, you deserve a sub , thanks man!@@pingcode
@@pingcode IT WORKED, THANKSSS you deserve a sub!!
@@pafodev No problem!
I don't know if someone will see this because it was posted 4 moths ago but I have this error that says
TypeError: Invalid first argument to `register()`
And I'm confused because when try and find a fix everything says 3.10.0 is'nt copatable with mlagents?
@iaxsgames6029 Are you working in a venv?
Is pip up to date?
Did you install packages when using python version 3.10.0 and not just switching python versions?
If yes to all then I really don't know. I made a dropbox link to my requirements.txt file if you want to try install everything using that?
www.dropbox.com/scl/fi/phe813xzccz69riaf678x/requirements.txt?rlkey=etb53insp2txwtz8x0yaqwmqx&st=vdsaergu&dl=0
Delete venv folder, and remake it. Put the file in the venv folder. Activate the venv and run *pip install -r requirements.txt*
@@pingcode Do You Know How To Increase max_steps because right now when I say
Mlagents-learn --run-id=****
It always pops up at the bottom
max_steps: 50000
So It alwasy ends early
@@iaxsgames6029 you have to edit a YAML configuration file somewhere within the files. Please watch a tutorial on using ML-Agents for that. Code monkey's tutorial talk about it!
im getting this error
If you are interested in one on one tutoring for beginner's/intermediate's, I offer it for a fair price. Email me: (mypingo7 [at] yahoo [dot] com) if you are interested!
i get this error at the end: TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.
What version of Python are you using?
@@pingcode sorry for the late reply, but i have 3.12.2
@@Spiex81 you need 3.10, check description
@@pingcode Ah ok thanks
i am getting the following error when i'm trying to run "pip install nlagents":
ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (numpy)
Many people are having this issue and the reason isn't quite clear. The most I found online about this issue is that Numpy and Python are conflicting with each other. Try to install a different version of numpy. Make sure pip is updated. Make sure you are using Python 3.10.0 in the terminal.
@@pingcode that's probably the problem because when i try to install numpy i'm getting this error (and i'm using python 3.10 and pip is updated):
(venv) C:\Users\yonat\ot>pip install numpy==1.19
Collecting numpy==1.19
Using cached numpy-1.19.0.zip (7.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [90 lines of output]
Running from numpy source directory.
:460: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py:73: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
required_version = LooseVersion('0.29.14')
C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(cython_version) < required_version:
performance hint: _common.pyx:275:19: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
performance hint: _common.pyx:299:19: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
performance hint: _common.pyx:322:50: Exception check after calling 'random_func' will always require the GIL to be acquired. Declare 'random_func' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
performance hint: _common.pyx:1002:32: Exception check after calling 'f1' will always require the GIL to be acquired. Declare 'f1' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
performance hint: _generator.pyx:706:41: Exception check after calling '_shuffle_int' will always require the GIL to be acquired.
Possible solutions:
1. Declare '_shuffle_int' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
2. Use an 'int' return type on '_shuffle_int' to allow an error code to be returned.
performance hint: _generator.pyx:735:45: Exception check after calling '_shuffle_int' will always require the GIL to be acquired.
Possible solutions:
1. Declare '_shuffle_int' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
2. Use an 'int' return type on '_shuffle_int' to allow an error code to be returned.
Error compiling Cython file:
------------------------------------------------------------
...
for i in range(1, RK_STATE_LEN):
self.rng_state.key[i] = val[i]
self.rng_state.pos = i
self._bitgen.state = &self.rng_state
self._bitgen.next_uint64 = &mt19937_uint64
^
------------------------------------------------------------
_mt19937.pyx:138:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to the type of the value being assigned.
Processing numpy/random\_bounded_integers.pxd.in
Processing numpy/random\bit_generator.pyx
Processing numpy/random\mtrand.pyx
Processing numpy/random\_bounded_integers.pyx.in
Processing numpy/random\_common.pyx
Processing numpy/random\_generator.pyx
Processing numpy/random\_mt19937.pyx
Traceback (most recent call last):
File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 235, in
main()
File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 231, in main
find_process_files(root_dir)
File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 222, in find_process_files
process(root_dir, fromfile, tofile, function, hash_db)
File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 188, in process
processor_function(fromfile, tofile)
File "C:\Users\yonat\AppData\Local\Temp\pip-install-ha3yov2t
umpy_1fff654732424398a076fa9ec2c2648c\tools\cythonize.py", line 77, in process_pyx
subprocess.check_call(
File "C:\Users\yonat\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Users\\yonat\\ot\\venv\\Scripts\\python.exe', '-m', 'cython', '-3', '--fast-fail', '-o', '_mt19937.c', '_mt19937.pyx']' returned non-zero exit status 1.
Cythonizing sources
Traceback (most recent call last):
File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in
main()
File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\yonat\ot\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 149, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 368, in prepare_metadata_for_build_wheel
self.run_setup()
File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 497, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\yonat\AppData\Local\Temp\pip-build-env-u1c354rr\overlay\Lib\site-packages\setuptools\build_meta.py", line 313, in run_setup
exec(code, locals())
File "", line 489, in
File "", line 469, in setup_package
File "", line 274, in generate_cython
RuntimeError: Running cythonize failed!
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
help me fix error: Failed building wheel for numpy, I am using python 3.10.2, numpy is 1.26.4. I got this error when pip install mlagents
use python 3.9
@@deoz210 Does 3.9 work with ml-agents 21
apologies for the late reply, if you still have the issue. Do you know what numpy version you have? You might have an older numpy version installed on your PC that isn't compatible with python 3.10
This issue page might be helpful to read what others have said. Someone mentions at the end they used numpy version 1.23.3 and it works
github.com/Unity-Technologies/ml-agents/issues/6008
@@pingcode I am running into the same issue. I am using Numpy 1.23.3 and python 3.10.0 and I also get the "ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects" message :/
Help would greatly be appreciated!
@@BastiaanNetjes I'm not sure since I never ran into this issue myself. The only thing I can suggest is to uninstall numpy and reinstall it to see if that fixes anything.
To my knowledge, you might also need C++ Build Tools installed since python and some libraries like numpy use C/C++. Though this is speculation.
Here is a link to the build tools: visualstudio.microsoft.com/visual-cpp-build-tools/
I could not why
you could not what?
@@pingcode to install ml agents i made all like you
@@calalmuradov6162 well, what is the problem?
Can you please help me with these???????? pleaseeeeeeeeeeeeeee
(venv) C:\Windows\System32>mlagents-learn --help
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib
unpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib
unpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Windows\System32\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in
File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\learn.py", line 2, in
from mlagents import torch_utils
File "C:\Windows\System32\venv\lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in
from mlagents.torch_utils.torch import torch as torch # noqa
File "C:\Windows\System32\venv\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in
from mlagents.trainers.settings import TorchSettings
File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\settings.py", line 25, in
from mlagents.trainers.cli_utils import StoreConfigFile, DetectDefault, parser
File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\cli_utils.py", line 5, in
from mlagents_envs.environment import UnityEnvironment
File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs\environment.py", line 48, in
from .rpc_communicator import RpcCommunicator
File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs
pc_communicator.py", line 1, in
import grpc
File "C:\Windows\System32\venv\lib\site-packages\grpc\__init__.py", line 22, in
from grpc import _compression
File "C:\Windows\System32\venv\lib\site-packages\grpc\_compression.py", line 20, in
from grpc._cython import cygrpc
ImportError: cannot import name 'cygrpc' from 'grpc._cython' (C:\Windows\System32\venv\lib\site-packages\grpc\_cython\__init__.py)
Are you using Python 3.10.0?
I can't help you with a random error message.
@@pingcode Yeah i am using the python 3.10.