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
@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
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!
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!
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. <string>: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 <module> 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 <module> 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 "<string>", line 489, in <module> File "<string>", line 469, in setup_package File "<string>", 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.
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*
@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
Can you please share more details as to what you are doing when you see the error? What command are you typing when you see this? What OS are you using?
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 <module> File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\learn.py", line 2, in <module> from mlagents import torch_utils File "C:\Windows\System32\venv\lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module> 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 <module> from mlagents.trainers.settings import TorchSettings File "C:\Windows\System32\venv\lib\site-packages\mlagents\trainers\settings.py", line 25, in <module> 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 <module> from mlagents_envs.environment import UnityEnvironment File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs\environment.py", line 48, in <module> from .rpc_communicator import RpcCommunicator File "C:\Windows\System32\venv\lib\site-packages\mlagents_envs pc_communicator.py", line 1, in <module> import grpc File "C:\Windows\System32\venv\lib\site-packages\grpc\__init__.py", line 22, in <module> from grpc import _compression File "C:\Windows\System32\venv\lib\site-packages\grpc\_compression.py", line 20, in <module> from grpc._cython import cygrpc ImportError: cannot import name 'cygrpc' from 'grpc._cython' (C:\Windows\System32\venv\lib\site-packages\grpc\_cython\__init__.py)
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.
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
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 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?
WHAT! i thought this channel has 100K+ subs! but u are only on 100+ !!!! HOW! Well, I have an issue! this is my code when i try to activate it: (venv) D:\apps\Learning AI>mlagents-learn --help Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "D:\apps\Learning AI\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module> File "D:\appsl\Learning AI\venv\Lib\site-packages\mlagents\trainers\learn.py", line 2, in <module> from mlagents import torch_utils File "D:\apps\Learning AI\venv\Lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module> from mlagents.torch_utils.torch import torch as torch # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\apps\Learning AI\venv\Lib\site-packages\mlagents\torch_utils\torch.py", line 6, in <module> from mlagents.trainers.settings import TorchSettings File "D:\appsl\Learning AI\venv\Lib\site-packages\mlagents\trainers\settings.py", line 5, in <module> from mlagents.trainers.settings import RewardSignalType, RewardSignalSettings ImportError: cannot import name 'RewardSignalType' from partially initialized module 'mlagents.trainers.settings' (most likely due to a circular import) (D:\appsl\Learning AI\venv\Lib\site-packages\mlagents\trainers\settings.py) (venv) D:\apps\Learning AI> I tried everything and i even asked CHATGPT! but i got no answer whope u will help... Also i am using python version 3.12.1 PLS HELP!
Thanks for the kind words. Don't use python 3.12. I don't think mlagents works with it yet. As I say in the video, use python 3.10.0. Link is in the description. You can just switch python versions in the terminal when following the tutorial.
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)
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!
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 ;)
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.
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/
great explanation, but whenerver i want to access the website now it keeps dowloading the file without loading the page (i got rid the code added added in the last section of the video but it still does the same)
Thanks! Without seeing your code I can't help you. If you want me to take a look at it, create an issue on the github page I made for this video. github.com/MyPingO/Refresh-Jinja-HTML-Example/issues This repository has the full complete code from the video which you can reference too!
In my case, I would call render_template() after the for loop in my progress() function. Once the code for whatever you are loading finishes, just call render_template like normal.
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
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/
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/
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!
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!
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!
When installing mlagents I get this: ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects. How do I fix this
i have it too and if i do it in Python 3.12.0 its giving me this: TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.
@@NikodemWisniewski-jp2bg I was able to install mlagents with python version 3.9.13, but there is a warning that 3.9.13 does not support pytorch but it can work
You don't know how much you've helped me with this one! I've been struggling for days with jquery and ajax... I've applied this in my app so when someones add a product to a shopping cart it doesn't refresh the page but hits the endpoint :) tytyty
How come you only got 2 digit subs?? The clarity of your teaching method, the structure, the presentation..all are awesome. You deserve a lot more subs Sir!! Great content! Are you planning to create more Flask videos? I'm rooting for them
Hey thanks for the kind words. To be honest I'm not sure. I wanted to make videos for things I couldn't find an answer for online. Those are probably the only ones to get viewed since they aren't anywhere else. Regular tutorials, even for flask are all over the internet so I'm not sure if I should make them. You can always leave a comment for a video request. If I know how to make a good video explaining that topic/question, I will