5

I am attempting to install cuda in WSL2 for use with TensorFlow (as per the TF instructions, which include the NVIDIA instructions).

The Windows-side tool nvidia-smi.exe works and gives the following output:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 517.40       Driver Version: 517.40       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
| 38%   28C    P8     7W / 120W |    473MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

I've made sure to install the correct cuda toolkit (the non-driver version of 11.7, as per the NVIDIA instructions) in WSL2. But when I run the WSL2-side tool nvidia-smi I see the following error:

Failed to initialize NVML: GPU access blocked by the operating system
Failed to properly shut down NVML: GPU access blocked by the operating system

Solutions from other posts (which include rebooting, reinstalling drivers, disabling secure boot, and upgrading to Windows 21H2) haven't worked for me.

How can I correctly configure cuda for WSL2?

(Edited for clarity)

3
  • Unfortunately, this suggests the fix to your problem is to upgrade to Windows 11 since 21359 is an expired insider Preview build from before Windows 11 was released. The current version build of Windows 10 21H2 is lower than 21359 and Windows 10 22H2 (not released yet) won’t fix it either. Even the Nvidia documentation indicates Windows 11 21H2 not Windows 10 21H2
    – Ramhound
    Oct 17, 2022 at 11:35
  • @Ramhound You might be right, but since GPU support is enabled on WSL2 on Windows 10, I believe the fix that you are referring to was backported to Windows 10 21H2. The Microsoft doc on the topic says that Windows 10 21H2 is supported. I just don't have any way of testing since the GPUs on all my older Windows 10 systems don't support it. Oct 17, 2022 at 12:27
  • @NotTheDr01ds - Author is already running 21H2. Github suggests this was a bug in Windows 10 that was fixed in a higher build than 21H2 is.
    – Ramhound
    Oct 17, 2022 at 12:46

1 Answer 1

5

"I've made sure to install the correct (i.e. non-driver) and matching version of the cuda toolkit in WSL2."

I don't think this is the right way to go here, because the NVIDIA instructions you linked say:

Use the latest Windows x86 production driver. R495 and later windows will have CUDA support for WSL 2.

I could imagine installing drivers inside WSL creates these problems. Recently I created a fresh Ubuntu WSL2 installation and did not install anything in it, nvidia-smi worked fine nevertheless.

2
  • I've been unclear: I haven't installed any drivers in WSL. I was referring to the WSL non-driver version of the cuda toolkit, provided in the NVIDIA instructions step 3.
    – mjmartis
    Oct 16, 2022 at 23:03
  • 2
    I can also confirm that I see the same error on a fresh Ubuntu WSL2 instance without anything installed.
    – mjmartis
    Oct 17, 2022 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.