pytorch / rl

A modular, primitive-first, python-first PyTorch library for Reinforcement Learning.
https://pytorch.org/rl
MIT License
2.27k stars 302 forks source link

Fix brax examples #2318

Closed Jendker closed 2 months ago

Jendker commented 2 months ago

Description

This fixes the brax examples. It explicitly specifies the device to run env on as recommended in the error messages.

Motivation and Context

This fixes the issues which I was getting with the original errors:

/home/jorbik/Projects/rl/torchrl/envs/libs/brax.py:207: UserWarning: No device is set for env BraxEnv(env=ant, batch_size=torch.Size([4]), device=None). Setting a device in Brax wrapped environments is strongly recommended.
  warnings.warn(
Traceback (most recent call last):
  File "/home/jorbik/Projects/rl/test.py", line 19, in <module>
    print(batch_size, timer.timeit(10))
                      ^^^^^^^^^^^^^^^^
  File "/home/jorbik/miniconda3/envs/torchrl/lib/python3.11/site-packages/torch/utils/benchmark/utils/timer.py", line 274, in timeit
    self._timeit(number=max(int(number // 100), 2))
  File "/home/jorbik/miniconda3/envs/torchrl/lib/python3.11/site-packages/torch/utils/benchmark/utils/timer.py", line 264, in _timeit
    return max(self._timer.timeit(number), 1e-9)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jorbik/miniconda3/envs/torchrl/lib/python3.11/timeit.py", line 180, in timeit
    timing = self.inner(it, self.timer)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<timeit-src>", line 6, in inner
  File "/home/jorbik/Projects/rl/torchrl/envs/common.py", line 2587, in rollout
    tensordicts = self._rollout_stop_early(**kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jorbik/Projects/rl/torchrl/envs/common.py", line 2674, in _rollout_stop_early
    tensordict = self.step(tensordict)
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jorbik/Projects/rl/torchrl/envs/common.py", line 1483, in step
    next_tensordict = self._step(tensordict)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jorbik/Projects/rl/torchrl/envs/libs/brax.py", line 418, in _step
    out = self._step_without_grad(tensordict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jorbik/Projects/rl/torchrl/envs/libs/brax.py", line 348, in _step_without_grad
    next_state = self._vmap_jit_env_step(state, action)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Received incompatible devices for jitted computation. Got ARG_SHARDING with device ids [0] on platform GPU and ARG_SHARDING with device ids [0] on platform CPU
--------------------
For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.

Closes #2319

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

Checklist

Go over all the following points, and put an x in all the boxes that apply. If you are unsure about any of these, don't hesitate to ask. We are here to help!

pytorch-bot[bot] commented 2 months ago

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2318

Note: Links to docs will display an error until the docs builds have been completed.

:x: 4 New Failures, 9 Unrelated Failures

As of commit b2cb6f6d3794a1cfb478a93d7533781573c8cedf with merge base 1ca33a2296a9e4f53db6b8ce855621a2eda5b246 (image):

NEW FAILURES - The following jobs have failed:

* [Continuous Benchmark (PR) / CPU Pytest benchmark](https://hud.pytorch.org/pr/pytorch/rl/2318#27879827688) ([gh](https://github.com/pytorch/rl/actions/runs/10079337606/job/27879827688)) `Workflow failed! Resource not accessible by integration` * [Continuous Benchmark (PR) / GPU Pytest benchmark](https://hud.pytorch.org/pr/pytorch/rl/2318#27879827981) ([gh](https://github.com/pytorch/rl/actions/runs/10079337606/job/27879827981)) `Workflow failed! Resource not accessible by integration` * [Generate documentation / build-docs (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879828925) ([gh](https://github.com/pytorch/rl/actions/runs/10079337626/job/27879828925)) `No files were found with the provided path: /home/ec2-user/actions-runner/_work/_temp/artifacts/. No artifacts will be uploaded.` * [Unit-tests on Windows / unittests-cpu / windows-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879829273) ([gh](https://github.com/pytorch/rl/actions/runs/10079337642/job/27879829273)) `The process 'C:\Program Files\Git\cmd\git.exe' failed with exit code 128`

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

* [Examples Tests on Linux / tests (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879828659) ([gh](https://github.com/pytorch/rl/actions/runs/10079337619/job/27879828659)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Habitat Tests on Linux / tests (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879828741) ([gh](https://github.com/pytorch/rl/actions/runs/10079337622/job/27879828741)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Libs Tests on Linux / unittests-gym (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879834702) ([gh](https://github.com/pytorch/rl/actions/runs/10079337635/job/27879834702)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Libs Tests on Linux / unittests-sklearn (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879834962) ([gh](https://github.com/pytorch/rl/actions/runs/10079337635/job/27879834962)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [RLHF Tests on Linux / unittests (3.9, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879828378) ([gh](https://github.com/pytorch/rl/actions/runs/10079337623/job/27879828378)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Unit-tests on Linux / tests-gpu (3.10, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879831435) ([gh](https://github.com/pytorch/rl/actions/runs/10079337620/job/27879831435)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Unit-tests on Linux / tests-olddeps (3.8, 11.6) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879831709) ([gh](https://github.com/pytorch/rl/actions/runs/10079337620/job/27879831709)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Unit-tests on Linux / tests-optdeps (3.10, 12.1) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879831948) ([gh](https://github.com/pytorch/rl/actions/runs/10079337620/job/27879831948)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128` * [Unit-tests on Linux / tests-stable-gpu (3.10, 11.8) / linux-job](https://hud.pytorch.org/pr/pytorch/rl/2318#27879832156) ([gh](https://github.com/pytorch/rl/actions/runs/10079337620/job/27879832156)) (matched **linux** rule in [flaky-rules.json](https://github.com/pytorch/test-infra/blob/generated-stats/stats/flaky-rules.json)) `The process '/usr/bin/git' failed with exit code 128`

This comment was automatically generated by Dr. CI and updates every 15 minutes.

facebook-github-bot commented 2 months ago

Hi @Jendker!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Jendker commented 2 months ago

Is it still required to sign Meta CLA? Isn't torchRL under PyTorch Foundation?

vmoens commented 2 months ago

Is it still required to sign Meta CLA? Isn't torchRL under PyTorch Foundation?

Here it's just doc so I'm moving forward but yeah the CLA is still there to be signed unfortunately