我有:
$ python
Python 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
>>> 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 |
+-----------------------------------------------------------------------------+
有没有办法可以解决这个问题而不必重新启动我的机器?我有 Ubuntu 20.04 和 PyTorch 1.6.0
重新启动机器后,我得到了以下信息:
最佳答案
这种情况经常发生在 ubuntu 用户身上(我不太确定其他发行版)。我注意到了这种行为,尤其是当我让机器处于 sleep 状态时。无需重新启动,您可以运行此 thread 中提到的以下命令sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm
关于python - 如何在不重新启动机器的情况下修复 torch.cuda.is_available() False 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64363633/