Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What version of Python and PyTorch are you using?

Discussion in 'ML-Agents' started by vooood69, Apr 12, 2023.

  1. vooood69

    vooood69

    Joined:
    Jul 20, 2013
    Posts:
    4
    What version of Python and PyTorch are you using?

    I tried with what is recommended in the documentation and after barely managing to install the recommended versions of Python and PyTorch and MLAgents then ML Agents decided not to work with some random protocol buffers error.

    What versions are you guys using?
     
  2. vooood69

    vooood69

    Joined:
    Jul 20, 2013
    Posts:
    4
    So, after all I managed to install the environment and get it going. These are the versions of Windows, Unity and Python I have.

    Win 11 Pro 10.0.22621 Build 22621
    Unity 2022.2.14f1
    Python 3.10.8

    Cloned release_20 of ml-agents to my drive and installed it from there (the last two pip3 commands).

    Here are the commands I used to setup everything, should be self-explanatory.

    Before installing ml-agents did the following changes to ml-agents-envs/setup.py
    Changed "numpy>=1.14.1", to "numpy>=1.14.1,<1.24", in line #54 and deleted line #60 "numpy==1.21.2",

    md python-envs
    python -m venv python-envs\sample-env
    .\python-envs\unityml-env\Scripts\Activate.ps1
    pip install --upgrade pip
    pip3 install torch==2.0.0+cu118 -f https://download.pytorch.org/whl/torch_stable.html
    pip3 uninstall numpy
    pip3 install numpy==1.23.5
    pip uninstall protobuf
    pip install protobuf==3.20.3
    pip3 install onnx==1.13.1
    cd <to wherever you cloned ml-agents>
    pip3 install -e ./ml-agents-envs
    pip3 install -e ./ml-agents


    Hope this helps someone, because I needed a day or two to figure it out.
     
  3. NotBoxhead

    NotBoxhead

    Joined:
    Jun 7, 2022
    Posts:
    1
    I've done this a handful of times in the last year, but this really help.

    Thanks man for making life that little bit smoother today :D
     
    vooood69 likes this.
  4. JackSainsbury

    JackSainsbury

    Joined:
    May 15, 2017
    Posts:
    1
    You are an absolute bloody legend. Follow these steps to the T and it'll work flawlessly.
     
    NotBoxhead likes this.
  5. Atilli

    Atilli

    Joined:
    Aug 31, 2022
    Posts:
    11
    yep, thanks. That's really clear. I was dreading having to one day start a fresh install.
     
    NotBoxhead likes this.
  6. moonlock

    moonlock

    Joined:
    Feb 28, 2022
    Posts:
    10
    This advice is fantastic. When trying to install I was having endless dependency confilcts that were seemingly impossible to reconcile. Using ubuntu 22.04 I did the following, based on the steps above:

    Cloned the mlagents repo
    Created completey basic anaconda environment with python 3.10.8
    Installed nothing and made no changes to the environment
    Navigated to ml-agents directory

    Ran:
    pip install -e ./ml-agents

    This allowed pip to resolve all the dependencies properly, and it installed eveything successfully in one step.

    After cloning and running these commands:

    conda create --name mlagents python==3.10.8
    conda activate mlagents
    cd ml-agents
    pip install -e ./ml-agents

    the command mlagents-learn would start the server successfully.

    I made no changes to the source.

    It got the right versions for everything, pytorch, protobuf, etc.
     
    Last edited: Sep 8, 2023
    NotBoxhead likes this.
  7. Hozgen90

    Hozgen90

    Joined:
    Jan 20, 2021
    Posts:
    19
    This works perfect ^^ thanks