Pytorch 1.6 does not detect CUDA (GPU) on Arch Linux

username: Wmog
cooked: <p>Hi,</p>
<p>PyTorch 1.6 does not seem to detect CUDA.</p>
<p>I installed it with the following command:</p>
<p><code>conda install pytorch torchvision cudatoolkit=10.2 -c pytorch</code></p>
<h2>Code example</h2>
<p>When I want to test whether CUDA is available:</p>
<pre><code class="lang-auto">&gt;&gt;&gt; torch.cuda.is_available()
False
</code></pre>
<h2>System Info</h2>
<p><code>python -m torch.utils.collect_env</code></p>
<p>returns</p>
<pre><code class="lang-auto">Collecting environment information...
PyTorch version: 1.6.0
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Arch Linux
GCC version: (GCC) 10.2.0
CMake version: Could not collect

Python version: 3.8
Is CUDA available: No
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce RTX 2080 Ti
Nvidia driver version: 455.28
cuDNN version: Probably one of the following:
/usr/lib/libcudnn.so.8.0.4
/usr/lib/libcudnn_adv_infer.so.8.0.4
/usr/lib/libcudnn_adv_train.so.8.0.4
/usr/lib/libcudnn_cnn_infer.so.8.0.4
/usr/lib/libcudnn_cnn_train.so.8.0.4
/usr/lib/libcudnn_ops_infer.so.8.0.4
/usr/lib/libcudnn_ops_train.so.8.0.4

Versions of relevant libraries:
[pip3] numpy==1.18.5
[pip3] torch==1.6.0
[pip3] torchtext==0.7.0
[pip3] torchvision==0.7.0
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               10.2.89              hfd86e86_1  
[conda] mkl                       2020.2                      256  
[conda] mkl-service               2.3.0            py38he904b0f_0  
[conda] mkl_fft                   1.2.0            py38h23d657b_0  
[conda] mkl_random                1.1.1            py38h0573a6f_0  
[conda] numpy                     1.19.2           py38h54aff64_0  
[conda] numpy-base                1.19.2           py38hfa32c7d_0  
[conda] pytorch                   1.6.0           py3.8_cuda10.2.89_cudnn7.6.5_0    pytorch
[conda] torchtext                 0.7.0                    pypi_0    pypi
[conda] torchvision               0.7.0                py38_cu102    pytorch
</code></pre>
<h2>My specifications</h2>
<ul>
<li>OS: Arch Linux</li>
<li>PyTorch version: 1.6</li>
<li>Python version: 3.8</li>
<li>CUDA/cuDNN version: 11.1 and 10.2 (tested with both)</li>
<li>GPU models and configuration: GeForce RTX 2080 Ti</li>
</ul>
<hr>
<p>Thank you in advance for your help.</p>

username: appleparan
cooked: <p>Check if CUDA is properly installed by <code>nvidia-smi</code> command</p>

username: Toby
cooked: <p>Can you try it with pip install: <code>pip install torch torchvision</code>, take from <a href="https://pytorch.org/" rel="noopener nofollow ugc">this link</a></p>

username: Wmog
cooked: <p><a class="mention" href="/u/appleparan">@appleparan</a> Of course I had already  checked whether CUDA is properly installed, here is the output:</p>
<pre><code class="lang-auto">+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.28       Driver Version: 455.28       CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce RTX 208...  Off  | 00000000:03:00.0  On |                  N/A |
|  0%   43C    P8    12W / 260W |    185MiB / 11016MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+`

...

</code></pre>
<p><a class="mention" href="/u/toby">@Toby</a> Same problem with PyTorch installed with <code>pip install torch torchvision</code>.</p>

username: xecal1111
cooked: <p>Since you are an arch user, are you using Linux kernel 5.9? Linux 5.9 has problems with CUDA. If so, try downgrading to Linux 5.8.</p>

username: Wmog
cooked: <p>Yes I use the Linux Kernel 5.9. Is there any work-around?</p>

username: xecal1111
cooked: <p>As far as I know, there is no work-around instead of downgrading to Linux Kernel 5.8 (or lower) and replacing nvidia driver (nvidia) to nvidia-dkms.</p>

username: Wmog
cooked: <p>Thank you. Effectively, I downgraded to the Linux Kernel 5.8.5 from Arch Linux Archive, I removed <code>nvidia</code>, then I first installed <code>linux-headers-5.8.5</code>, then <code>nvidia-dkms</code>; it is worth noting that <code>linux-headers-5.8.5</code> must imperatively be installed before <code>nvidia-dkms</code>, otherwise the kernel headers of the Linux kernel 5.8.5 will be missing for <code>nvidia-dkms</code>.</p>
<p>Now it works and PyTorch detects CUDA.</p>

username: xecal1111
cooked: <p>Great that you fixed it!</p>