Search Unity

Installation and documentation is a pain !

Discussion in 'ML-Agents' started by virajvaitha1995, Jan 1, 2022.

  1. virajvaitha1995

    virajvaitha1995

    Joined:
    Mar 22, 2020
    Posts:
    13
    Hi all,

    I managed to install Unity ML-Agents in the past as the documentation was slightly more detailed, with a table showing what versions to use for the unity package and python package.

    The getting started and installation guide really does take you all over the place.

    It seems simple enough:
    - Install the verified ML Agents package from Unity

    - Clone the repository from branch 18 if you want to use the example environments

    - pip install relevant ML-Agents and Pytorch package at the correct python version in a conda environment.


    After this I am faced with countless complier issues. I'm not positing the details of the error cause I can figure it out and install it myself, but it shouldn't be this complicated!

    The getting started guide or installation guide should mention the version of python, python package and Unity package for the current up to date successful install in one document.

    Please could someone tell me the following:

    - Version of MLAgents to install from package registry
    - What repo branch to clone for this version
    - I will use this repo to install the extra . extensions package
    - version of python + Pytorch and MLagents

    I really love what your trying to achieve here and I know these things take time. Ideally the installation guide and installation itself is simplified as soon as possible.
    Thanks,
     
    jwadow likes this.
  2. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    Here's what worked for me recently on Windows and Mac OS, using Conda:

    Created and activated Conda environment with Python 3.7
    pip install mlagents (did install version 0.27.0 and dependencies incl. PyTorch on Mac, but PyTorch needs to be installed prior to ML-Agents on Windows)

    Unity project, manifest.json

    {
    "dependencies": {
    "com.unity.ml-agents": "2.1.0-exp.1",
    ...

    What kind of errors are you getting?
     
  3. virajvaitha1995

    virajvaitha1995

    Joined:
    Mar 22, 2020
    Posts:
    13
    Thanks for replying!

    There is a table on this website which indicated which files and unity packages to install.
    https://github.com/Unity-Technologies/ml-agents/tree/release_18_docs

    I followed the row for release 18 since this is the one called "stable" and to get started with.

    1) I downloaded the repo through this webpage (release_18), and also tried cloning the release 18 branch when I faced errors
    2) I installed the MLAgents package 2.1.0 and the the .extensions from the cloned repo (advanced installation steps) into unity package manager.
    3) I pip installed pytorch 1.7.1 and python package ml-agents =0.27.0

    This is 2 of 32 errors seen:
    Assets\ML-Agents\Examples\PushBlockWithInput\Scripts\PushBlockActions.cs(15,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\ML-Agents\Examples\PushBlockWithInput\Scripts\PushBlockWithInputPlayerController.cs(54,26): error CS0246: The type or namespace name 'InputAction' could not be found (are you missing a using directive or an assembly reference?)

    This looks like a common problem mentioned by others online on Youtube and stackoverflow, but I would think the issue is solved within the repo considering it is the latest stable version?

    I don't think it's to do with python /Pytorch /MLAgents version installed in conda as I haven't used them.

    It's more related to the cloned repo, and the version of Unity MLAgents (and extension) installed into Unity.

    I hope this makes sense. I really don't want to invest to much time with a significantly older version and this open source library is really amazing, I just want to get started as soon as possible.

    Thanks !
     
  4. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
  5. virajvaitha1995

    virajvaitha1995

    Joined:
    Mar 22, 2020
    Posts:
    13
    Yep exactly, when I open the demo project.

    I git clone the branch 18.

    From the package manager (advanced installation), I install the MLAgents and .extentions Unity Package from the same repository.

    I drag and drop the folders from Project into Unity, and see a ton of complier errors:

    Assets\ML-Agents\Examples\PushBlockWithInput\Scripts\PushBlockWithInputPlayerController.cs(54,26): error CS0246: The type or namespace name 'InputAction' could not be found (are you missing a using directive or an assembly reference?)

    The manifest is great to show all the different versions, but I have followed the installation of the correct versions from their docs.

    Thanks,

    Viraj
     
  6. virajvaitha1995

    virajvaitha1995

    Joined:
    Mar 22, 2020
    Posts:
    13
    Hey mbaske,

    Firstly just want to say thank you for all your help.

    Basically, the main error was related to one specific game environment. I just decided to delete that entire environment.

    When you said "error with demo project" it made me realize MLAgents is working fine, it's just not working for one specific demo (example environment). I deleted that game PushBlockWithInputPlayerController.cs and everything looks fine.

    I come from a Machine Learning background in Python (with some experience in OpenAI gym). I have only started learning how to create games now, so I can make more use out of MLAgents.

    I can finally begin MLAgents journey properly.
    Level 1) Use example environment, see if you can change some parameters to improve training
    Level 2) Create your own game, or adjust the reward structure of the current example games to see if I can improve training.

    If you have any recommendations or tips please let me know.

    Thanks once again and good luck with your work!
     
    mbaske likes this.
  7. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    185
    I totally agree, the information on the github site is all over the place and to just find the right site with the current releases, I had to google it bc otherwise I could not find it.

    Anyway, my superb expert tip is: Watch the CodeMonkey setup video. Always works with his video.
     
    shyamarama likes this.
  8. eryberto87

    eryberto87

    Joined:
    May 2, 2022
    Posts:
    3
    I am really tired, tried six different tutorial, read the documentation and I still have the same issue.
    No damn example is showing in the assets.
    Please someone clarifies what I am doing wrong.

    1. Opened a new Project
    2. Install ML agents from package manager
    3. Download package extension
    4. Through package manager install package from file>select phe package.json and this should be it (of course the virtual environment, pythorch)

    No example is showing in the asset folder
     
    crawfis likes this.
  9. iffalseelsetrue

    iffalseelsetrue

    Joined:
    May 3, 2018
    Posts:
    11
    hey Eryberto87
    the examples are saved in this folder of the repository, you need to download it separately to your computer.

    ml-agents/Project/Assets/ML-Agents/Examples/
     
  10. virajvaitha1995

    virajvaitha1995

    Joined:
    Mar 22, 2020
    Posts:
    13
    mbaske likes this.
  11. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    Fighting with them rocket science since a few hours and at least got the samples to compile and work.
    Point is you need to copy everything from repo (ml-agents/Project/Assets) into your Assets folder
     
  12. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    Trying to get this going. Do I need to install PyTorch for every project or is this a one time thing?