# Enabling GPU acceleration on Ubuntu on WSL2 with the NVIDIA CUDA Platform Reference: > https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#5-enjoy-ubuntu-on-wsl **Official script:** `curl https://ollama.ai/install.sh | sh` ![image](https://hackmd.io/_uploads/rk3F49kSa.png) ## 1. Install the appropriate Windows vGPU driver for WSL Please refer to the official [WSL documentation](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) for up-to-date links matching your specific GPU vendor. ![image](https://hackmd.io/_uploads/By7woK1Bp.png) ![image](https://hackmd.io/_uploads/H1rojYJSp.png) ## 2. Install NVIDIA CUDA on Ubuntu The following commands will install the WSL-specific CUDA toolkit version 11.6 on Ubuntu 22.04 AMD64 architecture. `sudo apt-key del 7fa2af80` Then setup the appropriate package for Ubuntu WSL: **Script** ``` #!/bin/bash wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub sudo add-apt-repository 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /' sudo apt-get update sudo apt-get -y install cuda ``` ## 3. Compile a sample application `mkdir sample && cd sample` ``` git clone https://github.com/nvidia/cuda-samples cd ~/sample/cuda-samples/Samples/1_Utilities/deviceQuery make ./deviceQuery ``` ![image](https://hackmd.io/_uploads/By6FqNHIT.png)