Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question ERROR: Failed building wheel for numpy

Discussion in 'ML-Agents' started by Alex_4x, Dec 2, 2023.

  1. Alex_4x

    Alex_4x

    Joined:
    Feb 2, 2014
    Posts:
    21
    I use instruction for installation ml agents
    https://unity-technologies.github.io/ml-agents/Installation
    • Windows 10.
    • Install Python 3.10.11
    • Install Conda
    • Install Git for windows
    • in Anaconda Prompt create environment
    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 https://github.com/Unity-Technologies/ml-agents.git

    • 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.
     
    Last edited: Dec 2, 2023
    AntonioModer likes this.
  2. brokenm

    brokenm

    Joined:
    Aug 28, 2014
    Posts:
    22
    Hey there,

    The numpy package version and python version are conflicting in the last release, but there is a workaround.

    Clone https://github.com/Unity-Technologies/ml-agents/tree/develop

    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
    https://github.com/Unity-Technologies/ml-agents/blob/develop/ml-agents-envs/setup.py
    https://github.com/Unity-Technologies/ml-agents/blob/develop/ml-agents/setup.py

    Create a new conda env with Python 3.9.18

    Install packages from source
    Code (Boo):
    1. cd /path/to/ml-agents
    2. python -m pip install ./ml-agents-envs
    3. python -m pip install ./ml-agents
     
  3. Alex_4x

    Alex_4x

    Joined:
    Feb 2, 2014
    Posts:
    21
    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?
     
  4. Jakopro

    Jakopro

    Joined:
    May 30, 2021
    Posts:
    18
    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:
    Code (Boo):
    1. conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
     
  5. brokenm

    brokenm

    Joined:
    Aug 28, 2014
    Posts:
    22
    @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
    Code (Boo):
    1. import  torch
    2.  
    3. torch.cuda.is_available()
     
  6. Alex_4x

    Alex_4x

    Joined:
    Feb 2, 2014
    Posts:
    21
    Hello. I try install pytorch-cuda and after them Learning not started :(
     
    akifpsh likes this.
  7. InitusInteractive

    InitusInteractive

    Joined:
    Aug 16, 2018
    Posts:
    128
    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?
     
  8. InitusInteractive

    InitusInteractive

    Joined:
    Aug 16, 2018
    Posts:
    128
    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
     
  9. Kiyodio

    Kiyodio

    Joined:
    Sep 27, 2019
    Posts:
    4
    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.
     
  10. deshpandearyan1

    deshpandearyan1

    Joined:
    Apr 13, 2021
    Posts:
    1
    thanks alot this helped !!!
     
  11. onurkarasurmeli

    onurkarasurmeli

    Joined:
    Jan 3, 2024
    Posts:
    1
    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