Search Unity

Question 'mlagents-learn' is not recognized as an internal or external command, operable program or batch fil

Discussion in 'ML-Agents' started by Oliver3557, Feb 28, 2022.

  1. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    After following this video tutorial:


    I get to the final command of entering:
    mlagents-learn Assets\Karting\Prefabs\AI\kart_mg_trainer_config.yaml --train --run-id=custom-track-1

    but I only get this error:
    'mlagents-learn' is not recognized as an internal or external command,
    operable program or batch file.
     
  2. weight_theta

    weight_theta

    Joined:
    Aug 23, 2020
    Posts:
    65
    Have you created a virtual environment i.e. conda environment and installed ml-agents toolkit using pip or so into that environment ? You should be able to run the shell file as followed:

    1. conda activate //anaconda3/envs/UnityML
    2. cd /Users/last_name/project_location
    3. chmod +x your_shell_file.sh
    4. ./your_shell_file.sh
     
  3. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    Idk I just followed the video, do I just need to enter these commands or download something? It doesn't say anything about anaconda, but I am wanting to use TensorFlow
     
  4. ChillX

    ChillX

    Joined:
    Jun 16, 2016
    Posts:
    145
  5. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
  6. ChillX

    ChillX

    Joined:
    Jun 16, 2016
    Posts:
    145
    Not sure what to say except that it works fine for me.

    Something is wrong with your environment. Maybe its the Python installation. Maybe its some of the dependencies. etc...
     
  7. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    I've completely reinstalled everything multiple times and tried multiple versions, desperate for it to work
     
  8. ChillX

    ChillX

    Joined:
    Jun 16, 2016
    Posts:
    145
    Just out of curiosity
    Did you cd to the directory where ML Agents is installed before running
    mlagents-learn

    in my case
    cd D:\MLUnity\ml-agents
     
  9. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    I restarted it all again and followed through the website instead: https://learn.unity.com/tutorial/karting-mod-smart-karts-training-guide#
    so the mlagents is installed through the command prompt, so I do not know where the directory would be for me?
    I am currently just trying to run it from my project directory
     
  10. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    Any chance you have a discord so I can show you screenshots and stuff easier / quicker? No worries if not.
     
  11. ChillX

    ChillX

    Joined:
    Jun 16, 2016
    Posts:
    145
    Its a path error. ML Agents is installed somewhere but that somewhere is not on the path.

    Simplest way:
    Download ML Agents Zip from GIT and unzip into a folder (or GIT Clone into a folder)

    Goto that folder in the python terminal window.
    Install the requirements / dependencies like Torch etc... (Probably already installed in your case but no harm either way)

    Then from the folder where you downloaded ML Agents or Git Cloned it.

    pip3 install -e ./ml-agents-envs
    pip3 install -e ./ml-agents

    At this point ML Agents is now installed in the folder where you downloaded it to or git cloned it to. Goto that folder and run mlagents-learn
     
  12. Oliver3557

    Oliver3557

    Joined:
    Nov 4, 2020
    Posts:
    7
    Thanks that stuff is good now I think, I also downloaded torch as I saw that on another thread. I now just get the error:
    Couldn't connect to trainer on port 5004 using API version 1.0.0. Will perform inference instead.
    I see people recommending to have the same version of C# and python but not sure how to check and other solutions for this didn't work.
    upload_2022-3-17_17-36-44.png