mihdalal/raps

Contradictory dependencies make building impossible

Closed this issue · 6 comments

Hello, and thanks for the cool repo on the paper.
I would like to use RAPS in another project but due to the contradictory dependencies in

REQUIRED_PACKAGES = ['Flask==1.0.2', 'matplotlib==2.0.2', 'plotly==4.0.0', 'numpy==1.16.0']
and
mujoco_py==2.0.2.13
matplotlib==3.3.4
tensorboard==2.5.0
with the rest of the repo, I get the following errors when setting it up:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-gpu 2.8.0 requires numpy>=1.20, but you have numpy 1.16.0 which is incompatible.
tensorflow-gpu 2.8.0 requires tensorboard<2.9,>=2.8, but you have tensorboard 2.5.0 which is incompatible.
pywavelets 1.3.0 requires numpy>=1.17.3, but you have numpy 1.16.0 which is incompatible.
pandas 1.3.5 requires numpy>=1.17.3; platform_machine != "aarch64" and platform_machine != "arm64" and python_version < "3.10", but you have numpy 1.16.0 which is incompatible.
metaworld 0.0.0 requires numpy>=1.18, but you have numpy 1.16.0 which is incompatible.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-gpu 2.8.0 requires tensorboard<2.9,>=2.8, but you have tensorboard 2.5.0 which is incompatible.
robosuite 1.2.0 requires mujoco-py==2.0.2.9, but you have mujoco-py 2.0.2.13 which is incompatible.
viskit 0.1 requires matplotlib==2.0.2, but you have matplotlib 3.3.4 which is incompatible.
viskit 0.1 requires numpy==1.16.0, but you have numpy 1.21.6 which is incompatible.

What should I do? Just ignore the version specification on the conflicting dependencies?

ignore all the complaints except the following: make sure to use mujoco_py==2.0.2.13.
If things still don't work let me know.
Thanks for bringing up this up, I will try to fix this sometime soon.

First of all, I am very grateful for such a speedy and helpful answer. Thank you!

Building works fine but I get the following error when attempting to use the environments (in this case, the microwave environment) :

$ python experiments/kitchen/dreamer/dreamer_v2_single_task_primitives.py --mode here_no_doodad --exp_prefix <> --env microwave
duplicate key ignored: env_name
2022-05-11 11:24:28.840313 WEST | Variant:
2022-05-11 11:24:28.840518 WEST | {
  "env_name": "",
  "algorithm": "DreamerV2",
  "version": "normal",
  "replay_buffer_size": 500000,
  "algorithm_kwargs": {
    "num_epochs": 250,
    "num_eval_steps_per_epoch": 30,
    "min_num_steps_before_training": 2500,
    "num_pretrain_steps": 100,
    "max_path_length": 5,
    "batch_size": 417,
    "num_expl_steps_per_train_loop": 30,
    "num_train_loops_per_epoch": 40,
    "num_trains_per_train_loop": 10
  },
  "use_raw_actions": false,
  "env_suite": "kitchen",
  "pass_render_kwargs": true,
  "save_video": true,
  "env_kwargs": {
    "dense": false,
    "image_obs": true,
    "action_scale": 1.4,
    "use_workspace_limits": true,
    "control_mode": "primitives",
    "usage_kwargs": {
      "use_dm_backend": true,
      "use_raw_action_wrappers": false,
      "use_image_obs": true,
      "max_path_length": 5,
      "unflatten_images": false
    },
    "image_kwargs": {}
  },
  "actor_kwargs": {
    "discrete_continuous_dist": true,
    "init_std": 0.0,
    "num_layers": 4,
    "min_std": 0.1,
    "dist": "tanh_normal_dreamer_v1"
  },
  "vf_kwargs": {
    "num_layers": 3
  },
  "model_kwargs": {
    "model_hidden_size": 400,
    "stochastic_state_size": 50,
    "deterministic_state_size": 200,
    "embedding_size": 1024,
    "rssm_hidden_size": 200,
    "reward_num_layers": 2,
    "pred_discount_num_layers": 3,
    "gru_layer_norm": true,
    "std_act": "sigmoid2"
  },
  "trainer_kwargs": {
    "adam_eps": 1e-05,
    "discount": 0.8,
    "lam": 0.95,
    "forward_kl": false,
    "free_nats": 1.0,
    "pred_discount_loss_scale": 10.0,
    "kl_loss_scale": 0.0,
    "transition_loss_scale": 0.8,
    "actor_lr": 8e-05,
    "vf_lr": 8e-05,
    "world_model_lr": 0.0003,
    "reward_loss_scale": 2.0,
    "use_pred_discount": true,
    "policy_gradient_loss_scale": 1.0,
    "actor_entropy_loss_schedule": "1e-4",
    "target_update_period": 100,
    "detach_rewards": false,
    "imagination_horizon": 5
  },
  "num_expl_envs": 5,
  "num_eval_envs": 1,
  "expl_amount": 0.3,
  "seed": "26475",
  "exp_id": "0",
  "exp_prefix": "05-11-microwave",
  "instance_type": "None",
  "exp_name": "05-11-microwave_2022_05_11_11_24_28_0000--s-26475"
}
~/anaconda3/envs/IKEA_2/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
~/anaconda3/envs/IKEA_2/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Process SpawnProcess-4:
Process SpawnProcess-1:
Traceback (most recent call last):
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/mujoco_vec_wrappers.py", line 72, in _worker
    env = env_fn_wrapper.var()
  File "~/xstar-raps/rlkit/rlkit/torch/model_based/dreamer/experiments/kitchen_dreamer.py", line 42, in <lambda>
    lambda: primitives_make_env.make_env(env_suite, env_name, env_kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 129, in make_env
    env = make_base_kitchen_env(env_name, env_kwargs_new)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 99, in make_base_kitchen_env
    env = ALL_KITCHEN_ENVIRONMENTS[env_class](**env_kwargs)
KeyError: ''
Traceback (most recent call last):
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/mujoco_vec_wrappers.py", line 72, in _worker
    env = env_fn_wrapper.var()
  File "~/xstar-raps/rlkit/rlkit/torch/model_based/dreamer/experiments/kitchen_dreamer.py", line 42, in <lambda>
    lambda: primitives_make_env.make_env(env_suite, env_name, env_kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 129, in make_env
    env = make_base_kitchen_env(env_name, env_kwargs_new)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 99, in make_base_kitchen_env
    env = ALL_KITCHEN_ENVIRONMENTS[env_class](**env_kwargs)
KeyError: ''
~/anaconda3/envs/IKEA_2/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Process SpawnProcess-3:
Traceback (most recent call last):
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/mujoco_vec_wrappers.py", line 72, in _worker
    env = env_fn_wrapper.var()
  File "~/xstar-raps/rlkit/rlkit/torch/model_based/dreamer/experiments/kitchen_dreamer.py", line 42, in <lambda>
    lambda: primitives_make_env.make_env(env_suite, env_name, env_kwargs)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 129, in make_env
    env = make_base_kitchen_env(env_name, env_kwargs_new)
  File "~/xstar-raps/rlkit/rlkit/envs/primitives_make_env.py", line 99, in make_base_kitchen_env
    env = ALL_KITCHEN_ENVIRONMENTS[env_class](**env_kwargs)
KeyError: ''
Traceback (most recent call last):
  File "experiments/kitchen/dreamer/dreamer_v2_single_task_primitives.py", line 139, in <module>
    exp_id=exp_id,
  File "~/xstar-raps/rlkit/rlkit/launchers/launcher_util.py", line 590, in run_experiment
    return run_experiment_here(method_call, **run_experiment_kwargs)
  File "~/xstar-raps/rlkit/rlkit/launchers/launcher_util.py", line 168, in run_experiment_here
    return experiment_function(variant)
  File "~/xstar-raps/rlkit/rlkit/torch/model_based/dreamer/experiments/kitchen_dreamer.py", line 45, in experiment
    expl_env = StableBaselinesVecEnv(env_fns=env_fns, start_method="fork")
  File "~/xstar-raps/rlkit/rlkit/envs/mujoco_vec_wrappers.py", line 134, in __init__
    observation_space, action_space = self.remotes[0].recv()
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/connection.py", line 407, in _recv_bytes
    buf = self._recv(4)
  File "~/anaconda3/envs/IKEA_2/lib/python3.7/multiprocessing/connection.py", line 379, in _recv
    chunk = read(handle, remaining)
ConnectionResetError: [Errno 104] Connection reset by peer

Mujoco-py version does not seem to be the culprit as I get the same result with 2.0.2.9, but for the record here are the versions of the relevant packages:

absl-py                   1.0.0                    pypi_0    pypi
awscli                    1.23.11                  pypi_0    pypi
boto                      2.49.0                   pypi_0    pypi
boto3                     1.22.10                  pypi_0    pypi
botocore                  1.25.11                  pypi_0    pypi
click                     8.0.1                    pypi_0    pypi
cloudpickle               1.6.0                    pypi_0    pypi
dmc2gym                   1.0.0                    pypi_0    pypi
flask                     1.0.2                    pypi_0    pypi
gtimer                    1.0.0b5                  pypi_0    pypi
gym                       0.18.3                   pypi_0    pypi
gym-notices               0.0.6                    pypi_0    pypi
h5py                      3.6.0                    pypi_0    pypi
ipdb                      0.13.9                   pypi_0    pypi
jmespath                  1.0.0                    pypi_0    pypi
lxml                      4.8.0                    pypi_0    pypi
matplotlib                3.3.4                    pypi_0    pypi
matplotlib-inline         0.1.3                    pypi_0    pypi
metaworld                 0.0.0                     dev_0    <develop>
mjrl                      1.0.0                    pypi_0    pypi
mujoco-py                 2.0.2.13                 pypi_0    pypi
numba                     0.53.1                   pypi_0    pypi
numpy                     1.21.6                   pypi_0    pypi
numpy-quaternion          2021.4.5.14.42.35          pypi_0    pypi
opencv-python             4.5.2.52                 pypi_0    pypi
pandas                    1.3.5                    pypi_0    pypi
pathtools                 0.1.2                    pypi_0    pypi
plotly                    4.0.0                    pypi_0    pypi
prometheus-flask-exporter 0.20.1                   pypi_0    pypi
psutil                    5.9.0                    pypi_0    pypi
pybullet                  1.9.5                    pypi_0    pypi
pyglet                    1.5.15                   pypi_0    pypi
pyquaternion              0.9.9                    pypi_0    pypi
python-dateutil           2.8.1                    pypi_0    pypi
scikit-image              0.17.2                   pypi_0    pypi
scipy                     1.4.1                    pypi_0    pypi
setproctitle              1.2.3                    pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
stable-baselines3         1.0                      pypi_0    pypi
tensorboard               2.5.0                    pypi_0    pypi
tensorboard-data-server   0.6.1                    pypi_0    pypi
tensorboard-plugin-wit    1.8.1                    pypi_0    pypi
tensorflow-estimator      2.2.0                    pypi_0    pypi
tensorflow-gpu            2.8.0                    pypi_0    pypi
tensorflow-io-gcs-filesystem 0.25.0                   pypi_0    pypi
tensorflow-probability    0.16.0                   pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
torch                     1.7.1                    pypi_0    pypi
torch-tb-profiler         0.4.0                    pypi_0    pypi
torchvision               0.8.2                    pypi_0    pypi

Closing the issue for now as so far, the fixes made to the dependencies seem to have worked (needs further testing).
Made a PR for the changes in #3.

ignore all the complaints except the following: make sure to use mujoco_py==2.0.2.13. If things still don't work let me know. Thanks for bringing up this up, I will try to fix this sometime soon.

Hi! @mihdalal

I like this repo but the installation of mujoco_py==2.0.2.13 on Ubuntu 20.04 has bothered me for a while. I have tried some other versions of mujoco_py but failed. Here is the error report:

Collecting mujoco-py==2.0.2.13
  Using cached mujoco-py-2.0.2.13.tar.gz (792 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: glfw>=1.4.0 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (2.6.5)
Requirement already satisfied: numpy>=1.11 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (1.21.6)
Requirement already satisfied: Cython>=0.27.2 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (0.29.37)
Requirement already satisfied: imageio>=2.1.2 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (2.9.0)
Requirement already satisfied: cffi>=1.10 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (1.15.1)
Requirement already satisfied: fasteners~=0.15 in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from mujoco-py==2.0.2.13) (0.19)
Requirement already satisfied: pycparser in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from cffi>=1.10->mujoco-py==2.0.2.13) (2.21)
Requirement already satisfied: pillow in /home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages (from imageio>=2.1.2->mujoco-py==2.0.2.13) (8.2.0)
Building wheels for collected packages: mujoco-py
  Building wheel for mujoco-py (pyproject.toml) ... error
  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 'c_warning_callback' 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 'c_warning_callback' 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 'c_error_callback' 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 'c_error_callback' 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 the type of 'c_warning_callback'.
      
      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 the type of 'c_error_callback'.
      Removing old mujoco_py cext /tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/generated/cymj_2.0.2.13_37_linuxcpuextensionbuilder_37.so
      Compiling /tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/cymj.pyx because it changed.
      [1/1] Cythonizing /tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/cymj.pyx
      Traceback (most recent call last):
        File "/home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/xzc/miniforge3/envs/raps/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 252, in build_wheel
          metadata_directory)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 417, in build_wheel
          wheel_directory, config_settings)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 488, in run_setup
          self).run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 51, in <module>
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-r84kppgi/normal/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 368, in run
          self.run_command("build")
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "<string>", line 29, in run
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/__init__.py", line 3, in <module>
          from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/builder.py", line 510, in <module>
          cymj = load_cython_ext(mujoco_path)
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/builder.py", line 105, in load_cython_ext
          cext_so_path = builder.build()
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/builder.py", line 221, in build
          built_so_file_path = self._build_impl()
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/builder.py", line 273, in _build_impl
          so_file_path = super()._build_impl()
        File "/tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/builder.py", line 234, in _build_impl
          dist.ext_modules = cythonize([self.extension])
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "/tmp/pip-build-env-r84kppgi/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: /tmp/pip-install-z8vf64ow/mujoco-py_dc515330567e4a798d1b83a984658820/mujoco_py/cymj.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mujoco-py
Failed to build mujoco-py
ERROR: Could not build wheels for mujoco-py, which is required to install pyproject.toml-based projects

Do you know how to fix it? Thanks in advance!

use an older python version, try python 3.8 - that fixes the issue for me

Thanks for your kind reply! I use mujoco_py==2.0.2.5 as an alternative for now and try to see if anything goes wrong. I will also try what you suggest.