Building Pytorch from source with cuda support on WSL2(Ubuntu 20.04, cuda11.4, Windows11)

For detailed information on step 1 ~ step 4, please refer to CUDA on WSL :: CUDA Toolkit Documentation (nvidia.com)https://docs.nvidia.com/cuda/wsl-user-guide/

  1. Upgrade to Windows11
  2. install cuda on WSL2(in my case, I am using Ubuntu 20.04 and cuda 11.4)
  3. install Nividia preview drivers on windows11
  4. install anaconda on WSL2
  5. create env in anaconda(in my case, I am using python=3.8.11)
  6. follow "build from source" steps on pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration (github.com)https://github.com/pytorch/pytorch
  7.  test if pytorch in WSL2 is using GPU acceleration
import torch
print(torch.cuda.is_available())
print(torch.cuda.current_device())
print(torch.cuda.device_count())
print(torch.cuda.get_device_name(0))

this should render an output similar to mine

True
0
1
NVIDIA GeForce RTX 2080 Ti

你可能感兴趣的:(pytorch,ubuntu,nvidia,cuda)