[Python] HOOMD-blue GPU error: "invalid device ordinal" in WSL2 despite CUDA and GPU detection

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to run HOOMD-blue 5.2.0 with GPU support inside WSL2 (Windows Subsystem for Linux), but I keep getting the following error:

    RuntimeError: CUDA Error: invalid device ordinal before /hoomd/Autotuner.h:497

    My setup:


    • WSL2 with Ubuntu 22.04


    • NVIDIA GPU: RTX 4060 with latest drivers


    • nvidia-smi works inside WSL and detects the GPU


    • HOOMD installed using:

      micromamba install hoomd=5.2.0

    • CUDA Toolkit version: 12.2 (also tried 11.8)
    Test script:


    import hoomd
    device = hoomd.device.GPU() # Also tried device_id=0 explicitly


    Calling GPU.get_available_devices() returns:

    ['[0]NVIDIA GeForce RTX 2060 30 SM_7.5 @ 1.68 GHz, 6143 MiB DRAM']


    So the GPU is detected. But as soon as I initialize the device, I get the "invalid device ordinal" error.

    Things I’ve tried:


    • Setting CUDA_VISIBLE_DEVICES=0


    • Explicitly passing device_id=0


    • Downgrading/upgrading HOOMD and CUDA versions


    • Installing with both conda and micromamba


    • Running minimal examples with just hoomd.device.GPU()

    None of these worked. The only configuration that runs is when I switch to hoomd.device.CPU(), but I need GPU acceleration.

    Questions:


    • Is HOOMD-blue fully compatible with GPU under WSL2?


    • If so, how can I fix the invalid device ordinal error (which seems to appear when neighbor lists are used)?


    • If not, is there a known workaround (besides switching to CPU or using native Windows/Linux)?

    Any insights from users who have successfully run HOOMD with GPU inside WSL2 would be much appreciated!

    Continue reading...

Compartilhe esta Página