Questions getting started with newer versions of rllib with tensorflow

  • High: It blocks me to complete my task.

I am trying to familiarize myself with new rllib features since it has been a while since I have look into it. I’m sure I’ve done something wrong because I can’t get past the first example. Here is step by step what I have done:

  1. Create a virtual environment on macos 13.6.4 with python 3.9.6: python3 -m venv my_venv
  2. Source virtual environment and update pip:
source my_venv/bin/activate
pip3 install -U pip
  1. Install rllib and tensorflow: pip3 install ray[rllib]==2.9.3 tensorflow. See pip list below
  2. Copy and paste the using python api example into a file.
  3. Run that file: python3 rllib_file.py
  4. Get framework error (not sure why pytorch was specified since I have tensorflow installed)
ImportError: PyTorch was specified as the framework to use (via `config.framework('torch')`)! However, no installation was found. You can install PyTorch via `pip install torch`.
  1. Add tf to config, so now config looks like this:
algo = (
    PPOConfig()
    .framework('tf')
    .rollouts(num_rollout_workers=1)
    .resources(num_gpus=0)
    .environment(env="CartPole-v1")
    .build()
)
  1. Run again, get strange errors:
Traceback (most recent call last):
  File "/Users/rusu1/abmarl/delete_me.py", line 7, in <module>
    PPOConfig()
  File "/Users/rusu1/.virtual_envs/my_venv/lib/python3.9/site-packages/ray/rllib/algorithms/algorithm_config.py", line 1137, in build
    return algo_class(
  File "/Users/rusu1/.virtual_envs/my_venv/lib/python3.9/site-packages/ray/rllib/algorithms/algorithm.py", line 516, in __init__
    super().__init__(
  File "/Users/rusu1/.virtual_envs/my_venv/lib/python3.9/site-packages/ray/tune/trainable/trainable.py", line 161, in __init__
    self.setup(copy.deepcopy(self.config))
  File "/Users/rusu1/.virtual_envs/my_venv/lib/python3.9/site-packages/ray/rllib/algorithms/algorithm.py", line 638, in setup
    self.workers = WorkerSet(
  File "/Users/rusu1/.virtual_envs/my_venv/lib/python3.9/site-packages/ray/rllib/evaluation/worker_set.py", line 181, in __init__
    raise e.args[0].args[2]
AttributeError: 'Variable' object has no attribute 'op'
  1. Try again with torch (removed ‘tf’ from ppo config argument), and it seems to work.

So looks like I’m having an issue with tensorflow (version 2.16). Any suggestions?

Here’s my_venv:

Package                      Version
---------------------------- -----------
absl-py                      2.1.0
aiosignal                    1.3.1
astunparse                   1.6.3
attrs                        23.2.0
certifi                      2024.2.2
charset-normalizer           3.3.2
click                        8.1.7
cloudpickle                  3.0.0
dm-tree                      0.1.8
Farama-Notifications         0.0.4
filelock                     3.13.3
flatbuffers                  24.3.25
frozenlist                   1.4.1
fsspec                       2024.3.1
gast                         0.5.4
google-pasta                 0.2.0
grpcio                       1.62.1
gymnasium                    0.28.1
h5py                         3.10.0
idna                         3.6
imageio                      2.34.0
importlib_metadata           7.1.0
jax-jumpy                    1.0.0
jsonschema                   4.21.1
jsonschema-specifications    2023.12.1
keras                        3.1.1
lazy_loader                  0.3
libclang                     18.1.1
lz4                          4.3.3
Markdown                     3.6
markdown-it-py               3.0.0
MarkupSafe                   2.1.5
mdurl                        0.1.2
ml-dtypes                    0.3.2
msgpack                      1.0.8
namex                        0.0.7
networkx                     3.2.1
numpy                        1.26.4
opt-einsum                   3.3.0
optree                       0.11.0
packaging                    24.0
pandas                       2.2.1
pillow                       10.3.0
pip                          24.0
protobuf                     4.25.3
pyarrow                      15.0.2
Pygments                     2.17.2
python-dateutil              2.9.0.post0
pytz                         2024.1
PyYAML                       6.0.1
ray                          2.9.3
referencing                  0.34.0
requests                     2.31.0
rich                         13.7.1
rpds-py                      0.18.0
scikit-image                 0.22.0
scipy                        1.13.0
setuptools                   58.0.4
shellingham                  1.5.4
six                          1.16.0
tensorboard                  2.16.2
tensorboard-data-server      0.7.2
tensorboardX                 2.6.2.2
tensorflow                   2.16.1
tensorflow-io-gcs-filesystem 0.36.0
termcolor                    2.4.0
tifffile                     2024.2.12
typer                        0.12.0
typer-cli                    0.12.0
typer-slim                   0.12.0
typing_extensions            4.10.0
tzdata                       2024.1
urllib3                      2.2.1
Werkzeug                     3.0.2
wheel                        0.43.0
wrapt                        1.16.0
zipp                         3.18.1