Posted at

【Deep Learningメモ】Jupyter NotebookでのGPU情報の確認方法

More than 1 year has passed since last update.

Jupyter Notebook上でGPUの情報を確認する方法を記載します.


目次


  • 1. 実行環境

  • 2. 各種確認


    • 2.1. TensorFlowのライブラリからデバイス設定を確認

    • 2.2. GPUの種類確認

    • 2.3. Cudaのバージョン確認

    • 2.4. GPUの使用状況確認

    • 2.5. NVIDIA DRIVERのバージョン確認



  • 3. 補足

  • 4. 参考リンク


1. 実行環境


2. 各種確認


2.1. TensorFlowのライブラリからデバイス設定を確認

from tensorflow.python.client import device_lib

device_lib.list_local_devices()

[name: "/device:CPU:0"

device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 8738958628955863132, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 11285974221
locality {
bus_id: 1
links {
}
}
incarnation: 17652009205189153751
physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7"]

CPUが利用できることを確認できた.


2.2. GPUの種類確認

%%bash

lspci | grep -i nvidia

00:1e.0 3D controller: NVIDIA Corporation GK210GL [Tesla K80] (rev a1)

Tesla K80が確認出来る


2.3. Cudaのバージョン確認

%%bash

nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

Cudaのバージョンは9.0


2.4. GPUの使用状況確認

%%bash

nvidia-smi

Mon Jul  9 23:09:59 2018       

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K80 On | 00000000:00:1E.0 Off | 0 |
| N/A 44C P0 70W / 149W | 10875MiB / 11439MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 7302 C ...naconda3/envs/tensorflow_p27/bin/python 10862MiB |
+-----------------------------------------------------------------------------+


2.5. NVIDIA DRIVERのバージョン確認

%%bash

cat /proc/driver/nvidia/version

NVRM version: NVIDIA UNIX x86_64 Kernel Module  384.111  Tue Dec 19 23:51:45 PST 2017

GCC version: gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)


3. 補足

Jupyter Notebookでlinux commandは下記の通り実行できます.

当たり前ですが,どちらも出力結果は同じ.


実行方法1

%%bash

nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176


実行方法2

!nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176


4. 参考リンク