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.
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”,
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.
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.