bloomberg / bloomberg/memray

CUDA driver fails to initialize in WSL

Open
#722 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15.2k
Forks
461
Avg merge
5d 3h
Merged PRs (30d)
10

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Current Behavior

When running profiler in WSL for CUDA-enabled Pytorch code, CUDA driver fails to initialize. Specifically, this happens after entering the `memray.Tracker` context manager.

```sh
$ python -m memray run -q -c 'import torch; print(torch.cuda.is_available())'
False
```

### Expected Behavior

CUDA driver being able to initialize,

```
$ python -m memray run -q -c 'import torch; print(torch.cuda.is_available())'
False
```

### Steps To Reproduce

1. WSL2 (Ubuntu 24.04), CUDA 12.7
2. Prepare python env:
```sh
$ pip install memray
$ pip install torch --index-url https://download.pytorch.org/whl/cu126
```
3. Run `python -m memray run -q -c 'import torch; print(torch.cuda.is_available())'`

### Memray Version

1.16.0

### Python Version

3.12

### Operating System

Linux

### Anything else?

I checked that this happens exactly in WSL environment. If I try to reproduce this in a Docker container of ubuntu:22.04 image, Docker engine being installed in the same WSL environment, CUDA successfully initializes.
Having read about [supported environments](https://bloomberg.github.io/memray/supported_environments.html#supported-operating-systems), I'm still not quite sure if WSL is supported or not.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `python -m memray run -q -c 'import torch; print(torch.cuda.is_available())'` in WSL2 Ubuntu 24.04, then compare it with the reported Docker result and the behavior inside `memray.Tracker`. Done means the CUDA driver initializes successfully when profiling the PyTorch command, with the expected CUDA availability result documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python, pytorch, ubuntu
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.