microsoft / microsoft/WSL

CUDA won't detect GPU in WSL

Open
#9,254 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

GPU
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

I tried setting up Pytorch with CUDA in WSL but it just doesn't pick up my GPU. `torch.cuda.is_available()` returns `False`.
----------------------------------------------------------------------------------------------------------------------------
```
#include
#include

int main(int argc, char** argv) {
int driver_version = 0, runtime_version = 0;

cudaDriverGetVersion(&driver_version);
cudaRuntimeGetVersion(&runtime_version);

printf("Driver Version: %d\n"
"Runtime Version: %d\n",
driver_version, runtime_version);

return 0;
}
```
This code, compiled with `nvcc`, just returns
```
Driver Version: 0
Runtime Version: 0
```
-------------------------------------------------------------------------------------------------------------------------
I'm on `Microsoft Windows [Version 10.0.19044.2251]`

And this is what `torch.utils.collect_env` outputs:
```
PyTorch version: 1.10.0+cu111
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31

Python version: 3.9.15 (main, Nov 24 2022, 14:31:59) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: 11.1.105
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==1.10.0+cu111
[pip3] torchaudio==0.10.0+rocm4.1
[pip3] torchvision==0.11.0+cu111
[conda] numpy 1.23.5 pypi_0 pypi
[conda] torch 1.10.0+cu111 pypi_0 pypi
[conda] torchaudio 0.10.0+rocm4.1 pypi_0 pypi
[conda] torchvision 0.11.0+cu111 pypi_0 pypi
```
This is `nvidia-smi` ran on the Windows host.
```
Sat Dec 03 00:22:29 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 457.51 Driver Version: 457.51 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 1060 WDDM | 00000000:01:00.0 On | N/A |
| N/A 65C P5 8W / N/A | 750MiB / 6144MiB | 28% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
```
-----------------------------------------------------------------------------------------------------------------------
I've tried what [this person suggested doing](https://github.com/pytorch/pytorch/issues/73487#issuecomment-1115441977), which is to install everything through `conda` in a new environment in a new WSL2, but it didn't work.

[From this thread](https://github.com/microsoft/WSL/issues/8174), there supposedly should be an `nvidia-smi` binary in `/usl/lib/wsl/lib/` but, on every single one of my WSL2 instance, there's only `. .. libd3d12.so libd3d12core.so libdxcore.so` there.

Does anyone have any ideas how I might get this working?
Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WSL2 GPU integration context and the reported /usl/lib/wsl/lib path, then compare the behavior described in the linked WSL and PyTorch issue threads. Reproduce the CUDA probe and torch.utils.collect_env output; done means identifying why GPU detection fails and documenting or validating a concrete fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux, pytorch
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.