WSL2 + CUDA + GeForce RTX 3090 not working

Aleksi_Ikkala: <p>Hi there,</p>
<p>For the life of me I cannot get PyTorch to work with CUDA in WSL2. I’ve been struggling with this problem for a couple of days now, and I’ve followed about every tutorial you can find online about how to make Torch+CUDA+WSL2 work (including <a href="https://docs.nvidia.com/cuda/wsl-user-guide/index.html" rel="noopener nofollow ugc">Nvidia’s</a> and <a href="https://christianjmills.com/Using-PyTorch-with-CUDA-on-WSL2/" rel="noopener nofollow ugc">this one</a>). Any help is much appreciated.</p>
<p><strong>Windows/WSL2 specs:</strong><br>
Windows 11, OS build 22000.376<br>
WSL2 kernel: 5.10.60.1-microsoft-standard-WSL2<br>
Ubuntu 20.04</p>
<p><strong>GPU specs:</strong><br>
Nvidia GeForce RTX 3090<br>
Nvidia Driver Version: 510.06 (from nvidia-smi)<br>
Cuda Version supported up to 11.6 (from nvidia-smi)</p>
<p>I installed PyTorch with CUDA support using conda packages: <code>conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch</code> (using Python 3.8.12)</p>
<p>However, running <code>torch.cuda.is_available()</code> returns <code>False</code> and e.g. <code>torch.zeros(1).cuda()</code> gives  <code>RuntimeError: No CUDA GPUs are available</code></p>
<p>Here’s the output from <code>collect_env.py</code>:</p>
<blockquote>
<p>Collecting environment information…<br>
PyTorch version: 1.10.1<br>
Is debug build: False<br>
CUDA used to build PyTorch: 11.3<br>
ROCM used to build PyTorch: N/A<br>
OS: Ubuntu 20.04.3 LTS (x86_64)<br>
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0<br>
Clang version: Could not collect<br>
CMake version: version 3.16.3<br>
Libc version: glibc-2.31<br>
Python version: 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:57:06)  [GCC 9.4.0] (64-bit runtime)<br>
Python platform: Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-glibc2.10<br>
Is CUDA available: False<br>
CUDA runtime version: Could not collect<br>
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090<br>
Nvidia driver version: 510.06<br>
cuDNN version: Probably one of the following:<br>
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.3.1<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.3.1<br>
HIP runtime version: N/A<br>
MIOpen runtime version: N/A<br>
Versions of relevant libraries:<br>
[pip3] numpy==1.21.2<br>
[pip3] torch==1.10.1<br>
[pip3] torchaudio==0.10.1<br>
[pip3] torchvision==0.11.2<br>
[conda] blas                      1.0                         mkl<br>
[conda] cudatoolkit               11.3.1               h2bc3f7f_2<br>
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch<br>
[conda] mkl                       2021.4.0           h06a4308_640<br>
[conda] mkl-service               2.4.0            py38h95df7f1_0    conda-forge<br>
[conda] mkl_fft                   1.3.1            py38h8666266_1    conda-forge<br>
[conda] mkl_random                1.2.2            py38h1abd341_0    conda-forge<br>
[conda] numpy                     1.21.2           py38h20f2e39_0<br>
[conda] numpy-base                1.21.2           py38h79a1101_0<br>
[conda] pytorch                   1.10.1          py3.8_cuda11.3_cudnn8.2.0_0    pytorch<br>
[conda] pytorch-mutex             1.0                        cuda    pytorch<br>
[conda] torchaudio                0.10.1               py38_cu113    pytorch<br>
[conda] torchvision               0.11.2               py38_cu113    pytorch</p>
</blockquote>
<p>I’ve tried building PyTorch from source as well, build is successful but alas the same problem persists.</p>
<p>For completeness sake, I should mention that if I install PyTorch with <code>cudatoolkit=10.2</code> then the GPU is found (<code>torch.cuda.is_available</code> returns <code>True</code>), but since GeForce RTX 3090 isn’t supported by CUDA 10 an error is produced for e.g. <code>torch.zeros(1).cuda()</code> saying that <code>NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.</code></p>
<p>When installing PyTorch in Windows (using conda and <code>cudatoolkit=11.3</code>) everything works perfectly.</p>

Aravind_Kota: <p>Hi, is there any solution to this issue. I am also facing same error when working with wsl2, pytorch and detectron2. My system details:<br>
GPU NVIDIA Quadro RTX 3000<br>
CUDA 11.6<br>
Driver Version 511.65</p>

Aleksi_Ikkala: <p>I didn’t manage to fix the problem. Switched to a dual boot (Ubuntu + Windows) instead.</p>

Earth_Three: <p>I have the same system and gpu sepcs as yours, and this works for me</p>
<pre><code class="lang-auto">conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
</code></pre>

AKAmer: <p>I can confirm that the solution provided by <a class="mention" href="/u/earth_three">@Earth_Three</a> has worked for me.</p>
<p>Here’s the system information from <code>nvidia-smi</code><br>
GPU: NVIDIA rtx3070<br>
Driver version: 497.29<br>
CUDA Version: 11.5</p>