Skip to content

viewer: --device=cpu#1107

Open
thowell wants to merge 1 commit intogoogle-deepmind:mainfrom
thowell:viewer_device
Open

viewer: --device=cpu#1107
thowell wants to merge 1 commit intogoogle-deepmind:mainfrom
thowell:viewer_device

Conversation

@thowell
Copy link
Collaborator

@thowell thowell commented Feb 2, 2026

make viewer compatible with device=cpu

mjwarp-viewer benchmarks/humanoid/humanoid.xml --nconmax=48 --njmax=128 --device=cpu

Copy link
Collaborator

@erikfrey erikfrey left a comment

Choose a reason for hiding this comment

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

Looks great, just a couple questions around keeping the code simple

opt = copy.copy(mjm.opt)
m = mjw.put_model(mjm)
if is_cuda:
with wp.ScopedCapture() as capture:
Copy link
Collaborator

Choose a reason for hiding this comment

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

scopedcapture has a device param - could you do that instead of adding the ScopedDevice above?

compute_cache.mkdir()

with wp.ScopedDevice(_DEVICE.value):
is_cuda = wp.get_device().is_cuda
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can use the graph itself as a sentinel, so this could be something like:

graph = _compile_step(m, d) if wp.get_device().is_cuda else None

then further down

if graph is None:
  print("Running Warp unoptimized on CPU.")
  mjw.step(m, d)  # warmup

...
if _VIEWER_GLOBAL_STATE["running"] or _VIEWER_GLOBAL_STATE["step_once"]:
  _VIEWER_GLOBAL_STATE["step_once"] = False
  if graph is None:
    mjw.step(m, d)
  else:
    wp.capture_launch(graph)
    wp.synchronize()

something like that?

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.

2 participants