重新启动 DLVM 后无法通过 Tensorflow/Pytorch 检测 GPU

pal*_*ion 5 google-cloud-platform pytorch google-dl-platform gcp-ai-platform-notebook

这个问题发生在我今天重新启动我的云笔记本服务器时。可以使用以下步骤重现:

  1. 使用 Tensorflow 或 Pytorch 和 GPU 创建 Google Cloud Notebook 服务器

  2. 启动服务器后,打开python控制台:

>>> import torch
>>> torch.cuda.is_available()
True
Run Code Online (Sandbox Code Playgroud)

CUDA 设备目前可用。

  1. 重启服务器,再次打开笔记本。
>>> import torch
>>> torch.cuda.is_available()
/opt/conda/lib/python3.7/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at  /opt/conda/conda-bld/pytorch_1614378098133/work/c10/cuda/CUDAFunctions.cpp:109.)
  return torch._C._cuda_getDeviceCount() > 0
False
Run Code Online (Sandbox Code Playgroud)

nvidia-smi 命令工作正常。

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.80.02    Driver Version: 450.80.02    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  Tesla T4            Off  | 00000000:00:04.0 Off |                    0 |
| N/A   43C    P0    16W /  70W |      0MiB / 15109MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Thu_Jun_11_22:26:38_PDT_2020
Cuda compilation tools, release 11.0, V11.0.194
Build cuda_11.0_bu.TC445_37.28540450_0
Run Code Online (Sandbox Code Playgroud)

这个问题也可以用TensorFlow复现。如何解决这种情况?

Cha*_*rti -1

选项 1:
升级笔记本实例的环境。请参阅链接进行升级。
可升级的笔记本实例为双盘,一张启动盘,一张数据盘。升级过程会将启动磁盘升级到新映像,同时保留数据磁盘上的数据。

选项 2:
通过 SSH 连接到笔记本虚拟机并运行命令link
执行命令后,cuda 版本将更新至 11.3,nvidia 驱动程序版本将更新至 465.19.01。
重新启动笔记本虚拟机。

注意: GPU 图像中的问题已得到解决。新笔记本将使用映像版本 M74 创建。关于新镜像版本尚未在google-public-issue-tracker中更新,但您可以在控制台中找到新镜像版本 M74。