Install PyTorch 2.8.0 + CUDA 12.8 in WSL Ubuntu 24.04/22.04 = ###### tags: `Note` 1. Uninstall the old version ```bash= $ sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" $ sudo rm -r /usr/local/cuda-X.X ``` 2. Install CUDA tool kit Check [CUDA on WSL User Guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html) first because version may vary. ```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 $ wget https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda-repo-wsl-ubuntu-12-8-local_12.8.0-1_amd64.deb $ sudo dpkg -i cuda-repo-wsl-ubuntu-12-8-local_12.8.0-1_amd64.deb $ sudo cp /var/cuda-repo-wsl-ubuntu-12-8-local/cuda-*-keyring.gpg /usr/share/keyrings/ $ sudo apt-get update $ sudo apt-get -y install cuda-toolkit-12-8 ``` 3. Add to `$PATH` ```bash= $ export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64 $ export CUDA_HOME=/usr/local/cuda-12.8 $ export PATH=$CUDA_HOME/bin:$PATH $ export PATH=/usr/local/cuda/bin:$PATH ``` 4. Install PyTorch ```bash= $ conda create -n myenv python=3.10 $ conda activate myenv (myenv) $ pip3 install torch torchvision ``` ↑ as for now (9/9/2025) or ```bash= (myenv) $ pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu128 ``` 5. Check GPU availability ```bash= (myenv) $ python >>> import torch >>> torch.cuda.is_available() ``` Should return `True` if you're lucky.
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.