# 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`

## 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.


## 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
```
