Skip to content

Add early CUDA availability check to mjwarp-viewer#1106

Closed
ritikkumar1212 wants to merge 1 commit intogoogle-deepmind:mainfrom
ritikkumar1212:cuda-check
Closed

Add early CUDA availability check to mjwarp-viewer#1106
ritikkumar1212 wants to merge 1 commit intogoogle-deepmind:mainfrom
ritikkumar1212:cuda-check

Conversation

@ritikkumar1212
Copy link

mjwarp-viewer currently prints "CPU-only mode" and later crashes with
RuntimeError: Must be a CUDA device.

This PR adds an early CUDA availability check after wp.init(), so the viewer
fails fast with a clear, actionable error message on machines without NVIDIA GPUs.

This improves UX for CPU-only users and avoids a deep Warp stacktrace.

@hartikainen
Copy link
Contributor

I think it would be good to support non-CUDA devices. warp-lang README says:

Warp can run on x86-64 and ARMv8 CPUs on Windows, Linux, and macOS.

I'm pretty close to getting this to work with the MJX frontend in google-deepmind/mujoco#2948. I'm pretty sure that warp would work pretty much out-of-the box.

@ritikkumar1212
Copy link
Author

Thanks for the feedback!

My understanding was that wp.ScopedCapture() currently requires CUDA, which is why I added the early guard to avoid the late runtime crash.
I’m happy to adjust this to allow CPU execution if we can bypass graph capture on non-CUDA devices (or fall back to the C engine / non-captured Warp path).
Could you suggest the preferred behavior for CPU? For example:
skip ScopedCapture and call mjw.step directly?
or auto-switch to EngineOptions.C?

Happy to update the PR accordingly.

@hartikainen
Copy link
Contributor

I'm no expert on this, but the warp-lang=1.11.0 Scoped Devices documentation at least provides an example for ScopedDevice("cpu"):

with wp.ScopedDevice("cpu"):
    # alloc and launch on "cpu"
    a = wp.zeros(n)
    wp.launch(kernel, dim=a.size, inputs=[a])

@thowell
Copy link
Collaborator

thowell commented Feb 2, 2026

@ritikkumar1212 thank you for contributing to mujoco warp!

#1107 should enable the viewer to be compatible with device=cpu

@thowell
Copy link
Collaborator

thowell commented Feb 9, 2026

with #1107 merged the viewer should now work on cpu with --device=cpu

@thowell thowell closed this Feb 9, 2026
@ritikkumar1212
Copy link
Author

That's great

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.

3 participants