Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

WSL NVIDIA Driver Setup and How It Works

· 6 min read · Home Tech

In this article
  1. How GPU Passthrough Works in WSL
  2. System Requirements for GPU Support
  3. Installing the Correct Driver on Windows
  4. What You Can Run with WSL GPU Support
  5. Common Problems and Troubleshooting
  6. WSL vs. Native Linux Dual Boot
  7. Frequently Asked Questions

You do not need to install a separate NVIDIA driver inside WSL; instead, you install the latest NVIDIA GeForce or RTX driver on your Windows host, and WSL automatically accesses that driver to provide GPU acceleration for Linux applications. This integration allows Linux binaries to run on Windows while utilizing the full power of your NVIDIA graphics card without complex configuration or dual-booting.

How GPU Passthrough Works in WSL

Unlike a traditional virtual machine where a guest operating system requires its own dedicated video drivers, WSL 2 uses a different approach. The Windows Subsystem for Linux architecture allows the Linux kernel (which runs inside a lightweight utility VM) to communicate directly with the Windows host kernel. When you install the NVIDIA driver on Windows, it includes a specific component designed for WSL. This component exposes the GPU hardware to the Linux environment, effectively "passing through" the graphics card capabilities.

This means the driver stack is shared. The user-mode driver components are specific to Linux, but they communicate with the kernel-mode driver running on Windows. This design ensures that you never have to worry about driver version mismatches between Windows and Linux, as the Windows driver handles all hardware interaction.

System Requirements for GPU Support

Not every version of WSL supports NVIDIA GPUs, and not every driver will work. To successfully use your NVIDIA card with WSL, you must meet specific software and hardware criteria.

  • WSL Version: You must be running WSL 2. The original WSL 1 does not support GPU acceleration because it lacks the Linux kernel required for hardware drivers.
  • Windows Build: You generally need Windows 10 (version 21H2 or later) or Windows 11. Earlier builds may lack the necessary kernel support for the GPU paravirtualization.
  • Driver Version: You must install an NVIDIA driver specifically released with WSL support. Older drivers (typically those released before late 2020) do not contain the WSL components.
  • Hardware: The GPU must be supported by the driver. Most modern NVIDIA GeForce, Quadro, and RTX cards are compatible, though extremely old architectures may not be.

Installing the Correct Driver on Windows

The installation process is straightforward, but it is critical to perform it on the Windows side, not inside the Linux terminal. Attempting to run the NVIDIA .run installer inside the Linux distribution will typically fail or break the integration.

  1. Check Windows Updates: Ensure your Windows 10 or Windows 11 installation is fully updated to get the latest WSL kernel components.
  2. Install WSL 2: Open PowerShell or Command Prompt as Administrator and run wsl --install. This enables the required features and downloads the Linux kernel. Reboot your computer if prompted.
  3. Download the Driver: Visit the official NVIDIA Driver Downloads website. Select your specific GPU model (e.g., GeForce RTX 3060) and ensure the "WHQL" or "Production Branch" driver is selected.
  4. Install on Windows: Run the downloaded executable. The installer will place the standard Windows drivers and the necessary WSL libraries on your system.
  5. Verify in Linux: Open your WSL terminal (e.g., Ubuntu) and run nvidia-smi. If the installation was successful, this command will output a table showing your GPU name, driver version, and memory usage.

What You Can Run with WSL GPU Support

The primary purpose of NVIDIA support in WSL is not to run graphical Linux desktop environments (though that is increasingly supported via WSLg), but to accelerate compute workloads. This is particularly valuable for developers and data scientists who prefer Linux tools but use Windows as their primary OS.

Key use cases include:

  • Machine Learning: Training models using frameworks like TensorFlow or PyTorch. These frameworks can detect the GPU through the standard CUDA libraries available in WSL.
  • Scientific Computing: Running simulations or calculations that leverage CUDA cores for parallel processing.
  • Containerized Workloads: Using Docker with NVIDIA Container Toolkit support. This allows you to run containers that require GPU access, which is a common workflow in AI development.

It is important to note that while CUDA applications run efficiently, full 3D gaming performance inside WSL is generally lower than running native Windows games, though the gap is narrowing with newer updates.

Common Problems and Troubleshooting

Even with the correct driver, users often encounter issues where the GPU is not detected inside the Linux environment. One frequent cause is a version mismatch or a pending Windows update.

If nvidia-smi returns a "command not found" error or fails to detect the driver:

  • Verify WSL Version: Run wsl -l -v in PowerShell. Ensure your Linux distribution is listed as version 2. If it is version 1, convert it using wsl --set-version 2.
  • Check the Driver: Open Windows Device Manager and ensure the display adapter shows your NVIDIA card without warning symbols. If the Windows driver is corrupted, the WSL driver will fail too.
  • Avoid Linux Installers: Do not try to install the proprietary NVIDIA driver using apt install nvidia-driver or the .run file inside WSL. This often overwrites the paravirtualized libraries provided by Windows and breaks the integration. If you have done this, you may need to uninstall the Linux package or reset your WSL instance.

WSL vs. Native Linux Dual Boot

Choosing between WSL and a native Linux installation often comes down to convenience versus absolute performance. WSL offers near-native performance for many compute tasks, but there are distinct differences.

In a dual-boot setup, the Linux OS has exclusive access to the hardware. This allows for maximum performance and full control over kernel parameters. However, it requires rebooting to switch operating systems and can be complex to set up.

WSL provides seamless integration. You can edit files in Linux while viewing them in Windows, and you can access the GPU without rebooting. The performance overhead is minimal for single-GPU setups, but there is a small latency penalty compared to bare metal. Additionally, WSL currently has limitations with certain advanced features like full VR support or multi-GPU configurations (SLI), which are better supported on native Linux or Windows.

Frequently Asked Questions

Do I need to install CUDA inside WSL?

No, the CUDA driver components are provided by the Windows host driver. However, you may need to install the CUDA Toolkit (the development libraries and compilers) inside your Linux distribution to build applications, but the driver itself comes from Windows.

Can I use AMD or Intel GPUs with WSL?

Yes, but the process differs. AMD and Intel support in WSL relies on different technologies (often utilizing DirectML or OpenCL). While NVIDIA support is the most mature for CUDA workloads, AMD and Intel support is available but may require different driver setups or APIs.

Does this work for gaming?

It is not intended for high-performance gaming. While WSLg allows you to run Linux GUI apps, the translation layer for graphics is optimized for compute and basic applications. Native Windows games will always perform better than running a Linux game through WSL.

Why does nvidia-smi show a different driver version in WSL?

The version reported by nvidia-smi inside WSL should match the Windows driver version. If it does not, or if it reports a very old version, it indicates that the Windows driver is outdated or that leftover libraries from a previous Linux driver installation are interfering.

Is it safe to overclock my GPU in WSL?

Overclocking settings applied in Windows (using tools like MSI Afterburner) generally apply to the WSL environment as well. However, overclocking can cause system instability and may affect hardware longevity or warranty, so it should be approached with caution regardless of the OS.