Skip to content

--gpu on on native Linux says "WSL2's lack" concurrent managed access when cuInit itself failed #1145

Closed

Description

@nathanneuro

What you did

bend gpu_probe_message.bend -o gpu && ./gpu --gpu on

inside a Docker container (nvidia/cuda:13.0.0-devel-ubuntu24.04, --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all)
on a native Ubuntu 22.04 host (not WSL), started without --device /dev/nvidia-uvm --device /dev/nvidia-uvm-tools.

What happened

$ ./gpu --gpu on
bend: --gpu on, but this binary found no usable GPU (a CUDA GPU needs concurrent managed access, which WSL2's lack)
$ echo $?
1

The machine is not WSL2, and the GPU has concurrent managed access. The real failure is earlier: in
that container cuInit(0) returns CUDA_ERROR_UNKNOWN (999). A 10-line Driver API probe in the same container:

without --device /dev/nvidia-uvm:  cuInit -> 999 CUDA_ERROR_UNKNOWN
with    --device /dev/nvidia-uvm:  cuInit -> 0 CUDA_SUCCESS, CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS = 1

With --device /dev/nvidia-uvm --device /dev/nvidia-uvm-tools the same binary prints 1048576 under --gpu on
(and the build writes gpu.gpu, which it does not do in the failing container).

The CUDA error is an environment problem, not a Bend one. The problem is the message. gpu_probe
(bend2/comp.ts, the BEND_CUDA branch) ignores the return codes of cuInit, cuDeviceGet,
cuDevicePrimaryCtxRetain and cuCtxSetCurrent, and returns a single bool. main then prints a fixed
explanation for every failure, and that explanation names WSL2. Printing the failing call and its cuGetErrorName would have
pointed straight at the driver/container setup. #1064 point 2 asked for this ("distinguish no driver, no device, no managed memory, no
concurrent managed access, and context failure"). The fix for #1064 changed the text, but it is still one reason for every
failure.

Default runs (no --gpu) fall back to the CPU silently in the failing container. This is documented
("A machine without a GPU runs ! on the CPU"), so it is not reported here.

The file

import Base

def pow2(+n: Nat) -> U32:
  match n:
    case 0n:
      1
    case 1n+p:
      a b = pow2(p) pow2(p)
      (a + b : U32)

def main() -> IO(Unit):
  IO.print(U32.show(pow2!(20n)))

(saved alongside as gpu_probe_message.bend; it is the GUIDE's example)

bend --version

bend 2.0.32. Reproduced with the release checkout (commit d2066a5) and with main at
b2111cf (2026-09-27), which also reports bend 2.0.32.

uname -sm

Linux x86_64. Container: Ubuntu 24.04, CUDA 13.0 (nvcc V13.0.48). Host: Ubuntu 22.04, kernel 6.8.0-138-generic,
2x RTX 4090, driver 580.65.06, Docker 28.3.3 with the NVIDIA runtime.

clang --version (the first line)

Ubuntu clang version 19.1.1 (1ubuntu1~24.04.2)


Internal notes (not for the issue):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions