I use instruction for installation ml agents
conda create -n mlagents21 python=3.10.12
in Anaconda Prompt set active environment
conda activate mlagents21
in Anaconda Promt install torch
pip3 install torch~=1.13.1 -f https://download.pytorch.org/whl/torch_stable.html
in Command Line Prompt clone ml-agnts.git
git clone --branch release_21 GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
in Anaconda Promt change dir to ml-agents, install ml-agents-envs
(mlagents21) C:\Users\UserName\ml-agents>python -m pip install ./ml-agents-envs
have error:
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
(mlagents21) C:\Users\UserName\ml-agents>python --version
Python 3.10.12
(mlagents21) C:\Users\UserName\ml-agents>pip --version
pip 23.3.1 from C:\ProgramData\anaconda3\envs\mlagents21\lib\site-packages\pip (python 3.10)
(mlagents21) C:\Users\UserName\ml-agents>pip3 list
Package Version
numpy 1.26.2
pip 23.3.1
setuptools 68.0.0
torch 1.13.1+cu117
typing_extensions 4.8.0
wheel 0.41.2
(mlagents21) C:\Users\UserName\ml-agents>conda list
packages in environment at C:\ProgramData\anaconda3\envs\mlagents21:
Name Version Build Channel
bzip2 1.0.8 he774522_0
ca-certificates 2023.08.22 haa95532_0
libffi 3.4.4 hd77b12b_0
numpy 1.26.2 pypi_0 pypi
openssl 3.0.12 h2bbff1b_0
pip 23.3.1 py310haa95532_0
python 3.10.12 he1021f5_0
setuptools 68.0.0 py310haa95532_0
sqlite 3.41.2 h2bbff1b_0
tk 8.6.12 h2bbff1b_0
torch 1.13.1+cu117 pypi_0 pypi
typing-extensions 4.8.0 pypi_0 pypi
tzdata 2023c h04d1e81_0
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wheel 0.41.2 py310haa95532_0
xz 5.4.2 h8cc25b3_0
zlib 1.2.13 h8cc25b3_0
Help me please.
1 Like
brokenm
December 2, 2023, 10:26pm
2
Hey there,
The numpy package version and python version are conflicting in the last release, but there is a workaround.
Clone GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
Drop minimum python version to 3.9.1 by replacing python_requires=">=3.10.1,<=3.10.12"
with python_requires=">=3.9.1,<=3.10.12"
in those files
import os
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install
import mlagents_envs
VERSION = mlagents_envs.__version__
EXPECTED_TAG = mlagents_envs.__release_tag__
here = os.path.abspath(os.path.dirname(__file__))
class VerifyVersionCommand(install):
"""
Custom command to verify that the git tag is the expected one for the release.
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
This differs slightly because our tags and versions are different.
"""
description = "verify that the git tag matches our version"
This file has been truncated. show original
import os
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install
from mlagents.plugins import ML_AGENTS_STATS_WRITER, ML_AGENTS_TRAINER_TYPE
import mlagents.trainers
VERSION = mlagents.trainers.__version__
EXPECTED_TAG = mlagents.trainers.__release_tag__
here = os.path.abspath(os.path.dirname(__file__))
class VerifyVersionCommand(install):
"""
Custom command to verify that the git tag is the expected one for the release.
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
This differs slightly because our tags and versions are different.
"""
This file has been truncated. show original
Create a new conda env with Python 3.9.18
Install packages from source
cd /path/to/ml-agents
python -m pip install ./ml-agents-envs
python -m pip install ./ml-agents
3 Likes
Alex_4x
December 3, 2023, 11:10am
3
Thanks a lot!
I followed your instructions and everything installed without errors.
One more question. I have already installed CUDA from CUDA Toolkit 12.5 Update 1 Downloads | NVIDIA Developer
and Successfully uninstalled torch-1.13.1+cu117
but ml-agents-learn use CPU
Version information:
ml-agents: 1.1.0.dev0,
ml-agents-envs: 1.1.0.dev0,
Communicator API: 1.5.0,
PyTorch: 2.1.1+cpu
Can cuda be used for ml-agents-learn?
Alex_4x:
Thanks a lot!
I followed your instructions and everything installed without errors.
One more question. I have already installed CUDA from https://developer.nvidia.com/cuda-downloads
and Successfully uninstalled torch-1.13.1+cu117
but ml-agents-learn use CPU
Version information:
ml-agents: 1.1.0.dev0,
ml-agents-envs: 1.1.0.dev0,
Communicator API: 1.5.0,
PyTorch: 2.1.1+cpu
Can cuda be used for ml-agents-learn?
I’m not quite sure about mlagents, but I had a really tough time once trying to install CUDA. It didn’t work if I downloaded from the website, but it worked when I installed it with anaconda.
Try this:
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
@Alex_4x Couple of speculations on possible issue:
pytorch with cuda support might be installed in different environment
not an nvidia gpu
This small python script should return True
import torch
torch.cuda.is_available()
Hello. I try install pytorch-cuda and after them Learning not started
1 Like
I managed to get the pip install to complete, however, now when I attempt to install ml-agents I get more version errors
python -m pip install mlagents==1.0.0
ERROR: Ignored the following versions that require a different python version: 0.10.0.dev0
Requires-Python >=3.6,<3.7; 0.5.0
Requires-Python >=3.6,<3.7; 0.6.0
Requires-Python >=3.6,<3.7; 0.7.0
Requires-Python >=3.6,<3.7; 0.8.0
Requires-Python >=3.6,<3.7; 0.8.1
Requires-Python >=3.6,<3.7; 0.8.2
Requires-Python >=3.6,<3.7; 0.9.0
Requires-Python >=3.6,<3.7; 0.9.1
Requires-Python >=3.6,<3.7; 0.9.2
Requires-Python >=3.6,<3.7; 0.9.3
Requires-Python >=3.6,<3.7; 1.0.0
Requires-Python >=3.10.1,<=3.10.12
Has anyone successfully installed this yet and if so, how was it done?
Seems to work now.
I have PyTorch Cuda 11.8 installed
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
…which matches my nvcc version
I ended up not installing the 1.0.0 version but the default version 1.1.0.dev0
I just typed
python -m pip install mlagents
I ignored the version , seems to be ok
Im gonna tell you guys my way of having a relatively working mlagents
I dont know if you’ll end up with the same “Worker 0 restarting” issue as me but its worth a shot for you to try out
Use python 3.10.3
Follow instructions in github mlagents page.
Once all is done, try running mlagents-learn --help
You may get a warning saying numpy failed to initialise
install numpy version 1.23 as this uses the correct API version, DO NOT install numpy 1.24 this will result in errors
install protobuf 3.20.3
as far as I know this should work pretty well.
Hope it helps!
P.S. Your training Should work, as far as im aware, its simply a warning as stated above. Your AI related files should save as normal but you may have the slight inconvenience of having to wait for mlagents to time out after ending your session for it to do so.
thanks alot this helped !!!
I have this issue on mac m1, ml agents release 21
File “/private/var/folders/t4/lnnmvmhd16xcy86b7d944kr40000gn/T/pip-install-p3b2gh_x/onnx_d1c9814fd9814b45a55155e99c401dd8/setup.py”, line 217, in run
subprocess.check_call(build_args)
File “/opt/anaconda3/envs/mlagents/lib/python3.10/subprocess.py”, line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/opt/homebrew/bin/cmake’, ‘–build’, ‘.’, ‘–’, ‘-j’, ‘8’]’ returned non-zero exit status 2.
[end of output]
note : This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for onnx
Running setup.py clean for onnx
Failed to build onnx
ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects