Found no NVIDIA driver on your system (but it's there!)

vdw: <p>I’ve added an GeForce GTX 1080 Ti into my machine (Running Ubuntu 18.04 and Anaconda with Python 3.7) to utilize the GPU when using PyTorch. Both cards a correctly identified:</p>
<pre><code class="lang-auto">$ lspci | grep VGA
03:00.0 VGA compatible controller: NVIDIA Corporation GF119 [NVS 310] (reva1)
04:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
</code></pre>
<p>The NVS 310 handles my 2-monitor setup, I only want to utilize the 1080 for PyTorch. I also installed the latest NVIDIA drivers that are currently in the repository and that seems to be fine:</p>
<pre><code class="lang-auto">$ nvidia-smi 
Sat Jan 19 12:42:18 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.87                 Driver Version: 390.87                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  NVS 310             Off  | 00000000:03:00.0 N/A |                  N/A |
| 30%   60C    P0    N/A /  N/A |    461MiB /   963MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 108...  Off  | 00000000:04:00.0 Off |                  N/A |
|  0%   41C    P8    10W / 250W |      2MiB / 11178MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+
</code></pre>
<p>Driver version 390.xx allows to run CUDA 9.1 (9.1.85) according the the <a href="https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#major-components" rel="nofollow noopener">NVIDIA docs</a>. Since this is also the version in the Ubuntu repositories, I simple installed the CUDA Toolkit with:</p>
<pre><code class="lang-auto">$ sudo apt-get-installed nvidia-cuda-toolkit
</code></pre>
<p>And again, this seems be alright:</p>
<pre><code class="lang-auto">$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
</code></pre>
<p>and</p>
<pre><code class="lang-auto">$ apt-cache policy nvidia-cuda-toolkit
nvidia-cuda-toolkit:
  Installed: 9.1.85-3ubuntu1
  Candidate: 9.1.85-3ubuntu1
  Version table:
 *** 9.1.85-3ubuntu1 500
        500 http://sg.archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
        100 /var/lib/dpkg/status
</code></pre>
<p>Lastly, I’ve installed PyTorch from scratch with conda</p>
<pre><code class="lang-auto">conda install pytorch torchvision -c pytorch
</code></pre>
<p>Also error as far as I can tell:</p>
<pre><code class="lang-auto">$ conda list
...
pytorch                   1.0.0           py3.7_cuda9.0.176_cudnn7.4.1_1    pytorch
...
</code></pre>
<p>However, PyTorch doesn’t seem to find CUDA:</p>
<pre><code class="lang-auto">$ python -c 'import torch; print(torch.cuda.is_available())'
False
</code></pre>
<p>In more detail, if I force PyTorch to convert a tensor <code>x</code> to CUDA with <code>x.cuda()</code> I get the error:</p>
<pre><code class="lang-auto">Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from 82 http://...
</code></pre>
<p>What am I’m missing here? I’m new to this, but I think I’ve checked the Web already quite a bit to find any caveats like NVIDIA driver and CUDA toolkit versions?</p>
<p><strong>EDIT:</strong> Some more outputs from PyTorch:</p>
<pre><code class="lang-auto">print(torch.cuda.device_count())   # --&gt; 0
print(torch.cuda.is_available())   # --&gt; False
print(torch.version.cuda)          # --&gt; 9.0.176
</code></pre>

guiyanzhong: <p>There is a version mismatch.  Your installed CUDA version is 9.1.  However, your PyTorch package is compiled with CUDA 9.0.</p>
<p>Possible solutions:</p>
<ol>
<li>Install CUDA 9.0 instead of 9.1, or,</li>
<li>Install PyTorch that is compiled with CUDA 9.1, if there isn’t one yet, you may need download PyTorch source code and compile by yourself.</li>
</ol>
<p>BTW, I myself failed install PyTorch with Anaconda Python 3.7, but succeeded with 3.6. (on Ubuntu 18.04)</p>
<p>Hope this helps.</p>

vdw: <p>As I know now, PyTorch comes with all the required CUDA, cuDNN, etc. code bundled in the binaries – I don’t need anything special that would require to compile the sources myself :). Hence, there’s no need to install the CUDA Toolkit at all, and in fact I removed it completely. Only the Nvidia drivers and PyTorch are needed.</p>
<p>I got it working at the moment, simply switching to a  single-card setup, i.e., I removed the “small” NVS 310 – initially, I wanted to keep that card to drive all graphical output and use the 1080 solely for number crunching. However, no combination of drivers or PyTorch version (incl. different CUDA version) worked. With only the 1080 it was smooth sailing and worked immediately. The main difference is, is that I can now a newer Nvidia driver, 415 instead of 390, the limit of the NVS 310.</p>
<p>Your comment that you had to downgrade to Python 3.6 sounds very interesting, though. I actually also tried what happens when using only the NVS 310. I knew that its compute capability was to low, but when I tested it a couple of months ago, I got the respective error messages (“Your card is too old” or something like this). But now, it could even find the Nvidia driver. PyTorch installs quite alright with Anaconda + Python 3.7, it just won’t run in CUDA mode. I will probably give a clean Anaconda + Python 3.6 a shot, just to see if it makes a difference for me. Otherwise, I will leave the NVS 310 out of the machine. I don’t even know, if there’s a serious advantage if the 1080 wouldn’t need to handle the graphics output.</p>
<p>Thanks a lot for your feedback!</p>

airzs: <p>I faced the same problem with you, and Ithink this is because system cannot find the driver of nvidia. Adding the path of nvidia into my system path may helps.</p>

vdw: <p>Thanks, but I probably will stick with my working solution, i.e., only using the 1080 without the NVS 310 in parallel. With this setup, everything went through without any issues.</p>

chan0park: <p>In my case (on a cluster with gpus), adding CUDA_VISIBLE_DEVICES=GPU_ID before the python command solved the problem. Instead of adding CUDA_VISIBLE_DEVICES in the command line, you can probably  just add a line  os.environ[“CUDA_VISIBLE_DEVICES”] =“GPU_ID” before import torch.</p>

SayedMaheen: <p>same problem here:  Found no NVIDIA driver on your system. Please check that you<br>
have an NVIDIA GPU and installed a driver from</p>

Kirk: <p>This works for me too</p>

AlbertZeyer: <p>Also check the newer posts:</p><aside class="quote quote-modified" data-post="1" data-topic="135701">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/z/65b543/48.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/pytorch-cannot-find-gpu-2021-version/135701">PyTorch cannot find GPU, 2021 version</a> 
  </div>
  <blockquote>
    Environment: 

Remote Linux with core version 5.8.0. I am not a super user.
Python 3.8.6
CUDA Version: 11.1
GPU is RTX 3090 with driver version 455.23.05
CPU: Intel Core i9-10900K
PyTorch version: 1.8.0+cu111
System imposed RAM quota: 4GB
System imposed number of threads: 512198
System imposed RLIMIT_NPROC value: 300

After I run the following code (immediately after I entered python3 command line, so nothing else run before): 
import os
os.environ['OPENBLAS_NUM_THREADS'] = '2'
import torch
torc…
  </blockquote>
</aside>
<aside class="quote quote-modified" data-post="1" data-topic="144374">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/magleb/48/46773_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/pytorch-does-not-see-cuda/144374">PyTorch does not see CUDA</a> <a class="badge-category__wrapper " href="/c/deployment/14"><span data-category-id="14" data-drop-close="true" class="badge-category " title="A category of posts focused on production usage of PyTorch. Mobile deployment is out of scope for this category (for now…  )"><span class="badge-category__name">deployment</span></span></a>
  </div>
  <blockquote>
    Virtualization: microsoft AWS server
Operating System: Ubuntu 18.04.6 LTS
Architecture: x86-64

nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.103.01   Driver Version: 470.103.01   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compu…
  </blockquote>
</aside>

<p>In my case, it did not found <code>libcuda.so</code>, although <code>nvidia-smi</code> worked fine. I just missed <code>/usr/lib/x86_64-linux-gnu</code> in my <code>LD_LIBRARY_PATH</code>. Adding that, then all worked fine.</p>