LoginSignup
172
141

More than 5 years have passed since last update.

UbuntuのOSやCPU, GPUの情報を確認するコマンド

Posted at

この記事の内容

  • UbuntuのshellからOSの情報と、CPU, GPUのハードウェア情報を確認するコマンドの解説をします。
  • UbuntuにCUDAやcuDNN, tensorflowをインストールする時によく使うと思います。

概要

  • OSのバージョン
$ lsb_release -a
  • カーネル
$ uname -a
  • CPU
$ sudo lshw -class processor
  • GPU
$ lspci | grep -i nvidia

OSのバージョン

  • OSのバージョンを確認します。
  • lsb_releaseコマンドでOSのディストリビューションやバージョンが確認できます。
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:    18.04
Codename:   bionic

OSのカーネル

-aオプションを付けると出せる情報が全部でます。

$ uname -a
Linux R7 4.15.0-23-generic #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

--kernel-releaseとか--kernel-versionとかって付けると、項目別に表示されて見やすいです。

$ uname --kernel-release
4.15.0-23-generic
$ uname --kernel-version
#25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018

CPUのハード情報

  • CPUの型番、コア数、論理コア数などを確認します。
  • いくつかの方法があります。

lshwで確認

何もオプションを付けない場合、以下のように様々な詳細な情報が表示されるのですが、長くて概要が掴みにくいです。

$ sudo lshw
r7                          
    description: Desktop Computer
    product: Alienware Aurora R7 (0858)
    vendor: Alienware
    version: 1.0.8
    serial: 6P39KP2
    width: 64 bits
    capabilities: smbios-3.1 dmi-3.1 smp vsyscall32
...
  • -class processorオプションを付けてCPUの情報だけに絞ってみます。
    • productからCPUの機種がIntel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    • configurationからcores=6 enabledcores=6 threads=12と言った情報が分かります。
$ sudo lshw -class processor
  *-cpu                     
       description: CPU
       product: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
       vendor: Intel Corp.
       physical id: 36
       bus info: cpu@0
       version: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
       serial: To Be Filled By O.E.M.
       slot: U3E1
       size: 2943MHz
       capacity: 4600MHz
       width: 64 bits
       clock: 100MHz
       capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp cpufreq
       configuration: cores=6 enabledcores=6 threads=12

/proc/cpuinfoで確認

やってみましょう。

$ cat /proc/cpuinfo
...

これも非常に長い情報が表示されるのでgrepで絞ります。

  • 物理CPUにはphysical idというidが降ってあるのでこれにuniqをかけます。
  • CPUが1つ認識されている場合はphysical idも1行だけ出てきます。
$ cat /proc/cpuinfo | grep 'physical id' | uniq
physical id : 0

同じようにgrepを使って様々な情報が見れます。

  • 物理コア数
$ cat /proc/cpuinfo | grep 'cpu cores' | uniq
cpu cores   : 6
  • 論理コア数
$ cat /proc/cpuinfo | grep 'processor' | uniq
processor   : 0
processor   : 1
processor   : 2
processor   : 3
processor   : 4
processor   : 5
processor   : 6
processor   : 7
processor   : 8
processor   : 9
processor   : 10
processor   : 11

GPUのハード情報

$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GP104 High Definition Audio Controller (rev a1)

先程はgrepして情報を絞りましたが、左端に出ているidを-sオプションに与える事で指定したデバイスだけ見る事ができます。

$ lspci -s 01:00.0 
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)

さらに-vを付ける事で詳しい情報が表示されます。

$ lspci -s 01:00.0 -v
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: Dell GP104 [GeForce GTX 1080]
    Flags: bus master, fast devsel, latency 0, IRQ 136
    Memory at eb000000 (32-bit, non-prefetchable) [size=16M]
    Memory at a0000000 (64-bit, prefetchable) [size=256M]
    Memory at b0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at e000 [size=128]
    Expansion ROM at 000c0000 [disabled] [size=128K]
    Capabilities: <access denied>
    Kernel driver in use: nouveau
    Kernel modules: nvidiafb, nouveau
172
141
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
172
141