python - 如何在不重新启动机器的情况下修复 torch.cuda.is_available() False 问题?

标签 python ubuntu pytorch

我有:

$ 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
重新启动机器后,我得到了以下信息:
enter image description here

最佳答案

这种情况经常发生在 ubuntu 用户身上(我不太确定其他发行版)。我注意到了这种行为,尤其是当我让机器处于 sleep 状态时。无需重新启动,您可以运行此 thread 中提到的以下命令sudo rmmod nvidia_uvmsudo modprobe nvidia_uvm

关于python - 如何在不重新启动机器的情况下修复 torch.cuda.is_available() False 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64363633/

相关文章:

python - 通过分组分隔列中的数据

python - 画中画: "Cannot uninstall ' ipython'。这是一个 distutils 安装的项目,因此我们无法准确确定..."

Python正则表达式删除非unicode字符

python - 为什么这不会陷入无限循环?

python - Popen 命令失败,返回码为 1

python - 在 Pytorch 中计算欧几里德范数.. 麻烦理解和实现

eclipse - Eclipse(Helios)上没有自动完成功能

linux - 查找 Ubuntu 启动过程中的时间消耗者

tensorflow - Torch JIT Trace = TracerWarning : Converting a tensor to a Python boolean might cause the trace to be incorrect

arrays - 两个一维 numpy/torch 数组的特殊索引以生成另一个数组