how to fix the torch.cuda.is_available() False problem without restarting the machine?
I have:
$ python
Python 3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.cuda.is_available()
False
&gt;&gt;&gt; quit()

$ nvidia-smi
Wed Oct 14 21:28:50 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06    Driver Version: 450.51.06    CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| 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 2070    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   47C    P8     9W /  N/A |   1257MiB /  7982MiB |     11%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1424      G   /usr/lib/xorg/Xorg                823MiB |
|    0   N/A  N/A      1767      G   /usr/bin/gnome-shell              407MiB |
|    0   N/A  N/A      6420      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      6949      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      7447      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      8888      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      9218      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      9282      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A     65854      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A     70801      G   /usr/lib/firefox/firefox            2MiB |
+-----------------------------------------------------------------------------+

Is there a way I could fix this problem without having to restart my machine?
I have Ubuntu 20.04 and PyTorch 1.6.0
After I restarted the machine, here's what I get:


This happens quite often to ubuntu users (I am not so sure about other distros). I have noticed this behavior especially when I leave my machine on sleep. Without restarting you could run the following commands as mentioned in this thread
sudo rmmod nvidia_uvm 
sudo modprobe nvidia_uvm
