Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix brax examples #2318

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Fix brax examples #2318

merged 1 commit into from
Jul 24, 2024

Conversation

Jendker
Copy link
Contributor

@Jendker Jendker commented Jul 24, 2024

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

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

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!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Copy link

pytorch-bot bot commented Jul 24, 2024

🔗 Helpful Links

🧪 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.

❌ 4 New Failures, 9 Unrelated Failures

As of commit b2cb6f6 with merge base 1ca33a2 (image):

NEW FAILURES - The following jobs have failed:

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

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

@facebook-github-bot
Copy link

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 [email protected]. Thanks!

@Jendker
Copy link
Contributor Author

Jendker commented Jul 24, 2024

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

Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@vmoens vmoens merged commit 8a74642 into pytorch:main Jul 24, 2024
32 of 46 checks passed
@vmoens
Copy link
Contributor

vmoens commented Jul 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] examples of brax in brax.py are failing on CUDA enabled machine
3 participants