jannerm / diffuser

Code for the paper "Planning with Diffusion for Flexible Behavior Synthesis"
https://diffusion-planning.github.io
MIT License
811 stars 125 forks source link

conda env create -f environment.yml #50

Open AasherH opened 10 months ago

AasherH commented 10 months ago

I cannot get the "conda env create -f environment.yml" command to work on my machine. I keep receiving the following errors:

Using cached gym-0.18.0.tar.gz (1.6 MB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'error'

Pip subprocess error: Running command git clone --filter=blob:none --quiet https://github.com/JannerM/doodad.git /tmp/pip-req-build-926mvkq8 Running command git checkout -b janner --track origin/janner Switched to a new branch 'janner' Branch 'janner' set up to track remote branch 'janner' from 'origin'. error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [1 lines of output] error in gym setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers. [end of output]

I have tried manually installing every dependency instead of using the .yml file but still have run into issues. Anyone have any fixes?

jannerm commented 10 months ago

What version of pip do you have?

AasherH commented 10 months ago

I am using pip 23.0.1. and Ubuntu 22.04. I also will note that when manually installing the dependencies in the .yml file, the main issues were compatibility between mujoco and gym. For example, commenting out the gym=0.18.0 installation in the .yml file, I get the following errors:

Pip subprocess error: Running command git clone --filter=blob:none --quiet https://github.com/JannerM/doodad.git /tmp/pip-req-build-z1m78mwk Running command git checkout -b janner --track origin/janner Switched to a new branch 'janner' Branch 'janner' set up to track remote branch 'janner' from 'origin'. Running command git clone --filter=blob:none --quiet https://github.com/aravindr93/mjrl /tmp/pip-install-xnyhflty/mjrl_e6e2358e931041e19fd0e94ac3e67343 error: subprocess-exited-with-error

× Building wheel for mujoco-py (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [95 lines of output] running bdist_wheel running build performance hint: mujoco_py/cymj.pyx:67:5: Exception check on 'c_warning_callback' will always require the GIL to be acquired. Possible solutions:

  1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
  2. Use an 'int' return type on the function to allow an error code to be returned. performance hint: mujoco_py/cymj.pyx:104:5: Exception check on 'c_error_callback' will always require the GIL to be acquired. Possible solutions:
  3. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
  4. Use an 'int' return type on the function to allow an error code to be returned.

    Error compiling Cython file:

    ... See c_warning_callback, which is the C wrapper to the user defined function ''' global py_warning_callback global mju_user_warning py_warning_callback = warn mju_user_warning = c_warning_callback ^

    mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char ) except nogil' to 'void ()(const char ) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char ) except nogil'.

    Error compiling Cython file:

    ... See c_warning_callback, which is the C wrapper to the user defined function ''' global py_error_callback global mju_user_error py_error_callback = err_callback mju_user_error = c_error_callback ^

    mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char ) except nogil' to 'void ()(const char ) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char ) except nogil'. Removing old mujoco_py cext /tmp/pip-install-xnyhflty/mujoco-py_ad196a9625654fe7992f3cbc753dd639/mujoco_py/generated/cymj_2.0.2.13_38_linuxcpuextensionbuilder_38.so

kensukenk commented 9 months ago

I have the same issues on ubuntu 20.04

kensukenk commented 9 months ago

I was able to resolve the issue with gym from https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ

I also ran into the second issue with mujoco-py but this issue went away after installing mujoco-py==2.0.2.5.

yibo2222 commented 7 months ago

I was able to resolve the issue with gym from https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ

I also ran into the second issue with mujoco-py but this issue went away after installing mujoco-py==2.0.2.5.

Can I see your environment.yml file? I tried your fix for the second issue, but my pip installation fails when I try create the environment

Lycanthropy-Tori commented 5 months ago

I am using pip 23.0.1. and Ubuntu 22.04. I also will note that when manually installing the dependencies in the .yml file, the main issues were compatibility between mujoco and gym. For example, commenting out the gym=0.18.0 installation in the .yml file, I get the following errors:

Pip subprocess error: Running command git clone --filter=blob:none --quiet https://github.com/JannerM/doodad.git /tmp/pip-req-build-z1m78mwk Running command git checkout -b janner --track origin/janner Switched to a new branch 'janner' Branch 'janner' set up to track remote branch 'janner' from 'origin'. Running command git clone --filter=blob:none --quiet https://github.com/aravindr93/mjrl /tmp/pip-install-xnyhflty/mjrl_e6e2358e931041e19fd0e94ac3e67343 error: subprocess-exited-with-error

× Building wheel for mujoco-py (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [95 lines of output] running bdist_wheel running build performance hint: mujoco_py/cymj.pyx:67:5: Exception check on 'c_warning_callback' will always require the GIL to be acquired. Possible solutions: 1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. 2. Use an 'int' return type on the function to allow an error code to be returned. performance hint: mujoco_py/cymj.pyx:104:5: Exception check on 'c_error_callback' will always require the GIL to be acquired. Possible solutions: 1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. 2. Use an 'int' return type on the function to allow an error code to be returned.

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      See c_warning_callback, which is the C wrapper to the user defined function
      '''
      global py_warning_callback
      global mju_user_warning
      py_warning_callback = warn
      mju_user_warning = c_warning_callback
                         ^
  ------------------------------------------------------------

  mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      See c_warning_callback, which is the C wrapper to the user defined function
      '''
      global py_error_callback
      global mju_user_error
      py_error_callback = err_callback
      mju_user_error = c_error_callback
                       ^
  ------------------------------------------------------------

  mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.
  Removing old mujoco_py cext /tmp/pip-install-xnyhflty/mujoco-py_ad196a9625654fe7992f3cbc753dd639/mujoco_py/generated/cymj_2.0.2.13_38_linuxcpuextensionbuilder_38.so

I have met same problem. Have you solved it right now?

staycoolish commented 5 months ago

If you install mujoco-py-2.0.2.8, the environment will be created, but then you won't be able to use it due to compatibility issues. I tried to use the planning prompt - before which I downloaded the weights following the tutorial page - and it didn't work. Here is the latest environment file I have:

name: diffuser
channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- setuptools == 63.2.0
- wheel == 0.38.4
- pip == 22.2.2
- patchelf 
- Cmake
- pip:
    - -f https://download.pytorch.org/whl/torch_stable.html
    - numpy
    - gym==0.18.0
    - mujoco-py==2.0.2.13
    - matplotlib==3.3.4
    - torch==1.9.1+cu111
    - typed-argument-parser
    - git+https://github.com/Farama-Foundation/d4rl@f2a05c0d66722499bf8031b094d9af3aea7c372b#egg=d4rl
    - scikit-image==0.17.2
    - scikit-video==1.1.11
    - gitpython
    - einops
    - ffmpeg
    - ffprobe
    - pillow==7.2.0
    - tqdm
    - pandas
    - wandb
    - flax >= 0.3.5
    - jax <= 0.2.21
    - ray==2.0.0
    - crcmod # for fast gsutil rsync on large files
    - google-api-python-client
    - cryptography
    - git+https://github.com/JannerM/doodad.git@janner
    - gdown>=4.6.0

It gives the wheel for mujoco-py error in Ubuntu 20.4.6. I opened another issue and shared a working environment.yml file there ( https://github.com/jannerm/diffuser/issues/58 ), the one from Diffusion Policy paper, but they seem to use free-mujoco-py, among with different packages.

NishanthARao commented 4 months ago

Here's what worked for me (Ubuntu 22.04):

  1. Downgraded Python 3.12 to Python 3.8 by using conda install python=3.8
  2. Install specific versions of setuptools and wheel: pip3 install setuptools==65.5.0 "wheel<0.40.0"
  3. Install cython<3 using pip3 install "cython<3"
  4. Replace mujoco-py==2.0.2.13 with mujoco-py==2.0.2.5

My environment.yml file looks like this:

name: diffuser
channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- pip
- patchelf
- pip:
    - -f https://download.pytorch.org/whl/torch_stable.html
    - setuptools==65.5.0
    - wheel<0.40.0
    - mujoco-py==2.0.2.5
    - numpy
    - gym==0.18.0
    - matplotlib==3.3.4
    - torch==1.9.1+cu111
    - typed-argument-parser
    - git+https://github.com/Farama-Foundation/d4rl@f2a05c0d66722499bf8031b094d9af3aea7c372b#egg=d4rl
    - scikit-image==0.17.2
    - scikit-video==1.1.11
    - gitpython
    - einops
    - ffmpeg
    - ffprobe
    - pillow
    - tqdm
    - pandas
    - wandb
    - flax >= 0.3.5
    - jax <= 0.2.21
    - ray==2.0.0
    - crcmod # for fast gsutil rsync on large files
    - google-api-python-client
    - cryptography
    - git+https://github.com/JannerM/doodad.git@janner
    - gdown>=4.6.0

Other minor fixes I had to make:

  1. Convert np.int to np.int64 in file buffer.py
  2. Fix errors pertaining to LibGLEW.so and LibGL.so - This link helped a lot!

https://github.com/yuqingd/sim2real2sim_rad/blob/master/README.md#debugging-common-installation-errors

staycoolish commented 3 months ago

After @NishanthARao 's version, which I couldn't build on Ubuntu 20.04, I tried using mujoco-py 2.0.2.5, and it worked. Here is the environment file:

name: diffuser
channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- setuptools == 63.2.0
- wheel == 0.38.4
- pip == 22.2.2
- patchelf == 0.15.0.0
- Cmake
- cython == 0.29.36
- pip:
    - -f https://download.pytorch.org/whl/torch_stable.html
    - numpy
    - gym==0.18.0
    - mujoco-py==2.0.2.5
    - matplotlib==3.3.4
    - torch==1.9.1+cu111
    - typed-argument-parser
    - git+https://github.com/Farama-Foundation/d4rl@f2a05c0d66722499bf8031b094d9af3aea7c372b#egg=d4rl
    - scikit-image==0.17.2
    - scikit-video==1.1.11
    - gitpython
    - einops
    - ffmpeg
    - ffprobe
    - pillow==7.2.0
    - tqdm
    - pandas
    - wandb
    - flax >= 0.3.5
    - jax <= 0.2.21
    - ray==2.0.0
    - crcmod # for fast gsutil rsync on large files
    - google-api-python-client
    - cryptography
    - git+https://github.com/JannerM/doodad.git@janner
    - gdown>=4.6.0

I only had to change np.int to np.int64 in file buffer.py (diffuser/datasets/).

richie-live commented 3 weeks ago