【问题标题】:Jupyter Lab not seeing GPU with tensorflowJupyter Lab 看不到 GPU 与 tensorflow
【发布时间】:2020-11-28 13:36:10
【问题描述】:

我在 ubuntu 18.04 服务器上安装了 jupyter lab。我已经安装了显卡并使用 python 3.6.9 安装了tenserflow 2.3.1(根据这些说明:https://www.tensorflow.org/install/gpu)。我必须将以下环境变量添加到 /etc/environment 才能使其工作:

export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64

但是,Jupyter 实验室没有看到我的 GPU!当我在 jupyter 实验室笔记本中运行 follownig 命令时

import tensorflow as tf
tf.config.experimental.list_physical_devices()

它返回以下内容:

JUPYTER LAB 笔记本的输出

[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
PhysicalDevice(name='/physical_device:XLA_CPU:0', device_type='XLA_CPU'),
PhysicalDevice(name='/physical_device:XLA_GPU:0', device_type='XLA_GPU')]

但是,当我在 ipython 笔记本(或 python3 交互式 shell 或从终端 in jupyter lab)中运行相同的两行时,我得到以下输出:

IPYTHON SHELL 的输出

2020-11-28 13:21:39.005815: 我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcuda.so.1 2020-11-28

13:21:39.083058:我 tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] 成功 从 SysFS 读取的 NUMA 节点具有负值 (-1),但必须有 至少有一个 NUMA 节点,所以返回 NUMA 节点为零 2020-11-28

13:21:39.083573:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] 找到设备 0 具有属性:pciBusID:0000:01:00.0 名称:GeForce RTX 2060 计算能力:7.5 coreClock:1.68GHz coreCount:30 deviceMemorySize:5.79GiB deviceMemoryBandwidth:312.97GiB/s

2020-11-28 13:21:39.083610: 我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcudart.so.10.1 2020-11-28

13:21:39.142212:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcublas.so.10 2020-11-28

13:21:39.172917:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcufft.so.10 2020-11-28

13:21:39.180484:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcurand.so.10 2020-11-28

13:21:39.244521:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcusolver.so.10 2020-11-28

13:21:39.259263:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcusparse.so.10 2020-11-28

13:21:39.370126:我 tensorflow/stream_executor/platform/default/dso_loader.cc:48] 成功打开动态库libcudnn.so.7 2020-11-28

13:21:39.370414:我 tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] 成功 从 SysFS 读取的 NUMA 节点具有负值 (-1),但必须有 至少有一个 NUMA 节点,所以返回 NUMA 节点为零 2020-11-28

13:21:39.371750:我 tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] 成功 从 SysFS 读取的 NUMA 节点具有负值 (-1),但必须有 至少有一个 NUMA 节点,所以返回 NUMA 节点为零 2020-11-28

13:21:39.372808:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] 添加可见 gpu 设备:0

Out[3]: [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:XLA_CPU:0', device_type='XLA_CPU'), PhysicalDevice(name='/physical_device:XLA_GPU:0', device_type='XLA_GPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

显然 ipython/python3 shell 可以看到它,但 jupyter lab 没有。

我什至尝试设置 LD_LIBRARY_PATH in jupyter lab via:

import os
os.environ['LD_LIBRARY_PATH'] = '/usr/local/cuda-10.2/lib64'

还是不行!

如何让 jupyter lab 查看我的 GPU,以便我可以在 GPU 而不是 CPU 上训练我的网络?

编辑 1:增加输出的清晰度

【问题讨论】:

  • 输出显示 jupyter lab 确实看到了 GPU,我不确定到底是什么问题。输出的哪一部分“清楚地”表明 jupyter lab 没有看到它?
  • 上面的 out[3] 使用的是 ipython 交互式 shell,而不是 jupyter 实验室笔记本的输出。做了一些研究,'XLA_GPU:0' 不是 GPU

标签: tensorflow jupyter-notebook jupyter-lab


【解决方案1】:

我在 Jupyter notebook 中遇到了同样的问题,因为我通过 conda 安装了 tensorflow,我需要手动添加路径变量。我也无法在笔记本中添加环境变量,所以我尝试在 jupyter 的kernel.json 中添加变量,它对我有用。它看起来像这样:

{
 "argv": [
  ...
 ],
 "env": {
    "LD_LIBRARY_PATH":"your_lib_path"
 },
...
}

【讨论】:

    猜你喜欢
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 2019-06-09
    • 2022-08-21
    • 2017-07-26
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    相关资源
    最近更新 更多