nvidia-smi 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.Rakefile.swp +0 -0
- data/.gitignore +1 -0
- data/History.txt +6 -0
- data/README.md +8 -2
- data/Rakefile +2 -2
- data/lib/nvidia-smi.rb +17 -4
- data/spec/nvidia-smi_spec.rb +49 -0
- data/version.txt +1 -1
- metadata +5 -5
- data/test/test_nvidia-smi.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59d2f12427c81967e6105f1ba8ab95d89ce2dae7
|
4
|
+
data.tar.gz: 92bfb4cb4e5e9956a4882aa37b9b6d7e208ba67a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8965df2a060fe90da32e74e9ea80d3cb54373941744e82f4feb4702e3eb3b1bfa472648a5d152edbe5d62a416ee2fb481fc24f8897a5b42b0cf98bddbffd39ca
|
7
|
+
data.tar.gz: abeb56805823fb128d91cb3ebc8b8b88ac6587cbb7ce0bf007825e2f8c5d3726e6ad625b7aa1c22e6e410365a8286b50282c8bd5571c79dfe010fb32eaa19d8c
|
data/.Rakefile.swp
ADDED
Binary file
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
[](https://badge.fury.io/rb/nvidia-smi)
|
2
|
+
|
1
3
|
nvidia-smi
|
2
4
|
===========
|
3
5
|
|
6
|
+
Get informations about the system's GPU(s), through nvidia-smi.
|
7
|
+
|
4
8
|
Features
|
5
9
|
--------
|
6
10
|
|
7
|
-
Get
|
11
|
+
* Get the number of GPUs seen by the driver
|
12
|
+
* Get the driver's version
|
13
|
+
* Get an array of Struct::Gpu objects with all relevant informations about each GPU
|
8
14
|
|
9
15
|
Examples
|
10
16
|
--------
|
@@ -42,7 +48,7 @@ License
|
|
42
48
|
|
43
49
|
The MIT License
|
44
50
|
|
45
|
-
Copyright (c) 2017
|
51
|
+
Copyright (c) 2017 Julien Cornuwel
|
46
52
|
|
47
53
|
Permission is hereby granted, free of charge, to any person obtaining
|
48
54
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
data/lib/nvidia-smi.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module NvidiaSmi
|
2
2
|
|
3
|
+
# :stopdoc:
|
4
|
+
|
5
|
+
# All the values we want to extract from nvidia-smi
|
3
6
|
@@nvidia_keys = [
|
4
7
|
'index',
|
5
8
|
'pci.bus',
|
@@ -22,32 +25,42 @@ module NvidiaSmi
|
|
22
25
|
'vbios_version'
|
23
26
|
]
|
24
27
|
|
28
|
+
# Attributes names in the return Struct, with _ instead of . to keep ruby happy
|
25
29
|
return_keys = @@nvidia_keys.map(&:clone).each do |s|
|
26
30
|
s.gsub!('.', '_')
|
27
31
|
end
|
28
32
|
|
33
|
+
# The structure containing all the values we have about a GPU
|
29
34
|
Struct.new('Gpu', *return_keys)
|
30
35
|
|
36
|
+
# :startdoc:
|
37
|
+
|
31
38
|
|
39
|
+
# Returns an Integer representing the number of GPUs seen by nvidia-smi
|
40
|
+
#
|
32
41
|
def self.gpu_count
|
33
42
|
`nvidia-smi --query-gpu=count --format=csv,noheader -i 0`.to_i
|
34
43
|
end
|
35
44
|
|
45
|
+
# Returns a String containing the driver's version
|
46
|
+
#
|
36
47
|
def self.driver_version
|
37
48
|
`nvidia-smi --query-gpu=driver_version --format=csv,noheader -i 0`.strip
|
38
49
|
end
|
39
50
|
|
51
|
+
# Returns an Array of Struct::Gpu
|
52
|
+
# The members of the struct are the values we extracted from nvidia-smi, as Strings.
|
53
|
+
#
|
40
54
|
def self.gpus
|
41
55
|
gpus = Array.new
|
42
|
-
|
56
|
+
`nvidia-smi --query-gpu=#{@@nvidia_keys.join(',')} --format=csv,noheader`.each_line do |line|
|
43
57
|
values = line.strip.split(',').each do |v|
|
44
58
|
v.strip!
|
45
59
|
end
|
46
|
-
|
47
60
|
gpus << Struct::Gpu.new(*values)
|
48
61
|
end
|
49
|
-
return gpus
|
50
|
-
end
|
51
62
|
|
63
|
+
gpus
|
64
|
+
end
|
52
65
|
end
|
53
66
|
|
data/spec/nvidia-smi_spec.rb
CHANGED
@@ -2,5 +2,54 @@
|
|
2
2
|
require File.expand_path('../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe NvidiaSmi do
|
5
|
+
|
6
|
+
context "when asked for the number of GPUs" do
|
7
|
+
it "should return the number of GPUs as an Integer" do
|
8
|
+
NvidiaSmi.should_receive(:`).with("nvidia-smi --query-gpu=count --format=csv,noheader -i 0").and_return("3")
|
9
|
+
expect(NvidiaSmi.gpu_count).to eq(3)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when asked the driver's version" do
|
14
|
+
it "should return the driver's version as a String" do
|
15
|
+
NvidiaSmi.should_receive(:`).with("nvidia-smi --query-gpu=driver_version --format=csv,noheader -i 0").and_return("384.90")
|
16
|
+
expect(NvidiaSmi.driver_version).to eq("384.90")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when asked the GPUs list" do
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
NvidiaSmi.should_receive(:`).with("nvidia-smi --query-gpu=index,pci.bus,name,uuid,temperature.gpu,fan.speed,memory.used,memory.total,memory.free,utilization.memory,utilization.gpu,power.draw,power.limit,pstate,clocks.gr,clocks.sm,clocks.mem,clocks.video,vbios_version --format=csv,noheader").and_return("0, 0x01, GeForce GTX 1060 3GB, GPU-57737cf0-1db6-4905-9caa-1eeb73beb974, 71, 54 %, 2404 MiB, 3013 MiB, 609 MiB, 74 %, 99 %, 106.27 W, 120.00 W, P2, 1860 MHz, 1860 MHz, 3802 MHz, 1670 MHz, 86.06.3C.00.8E")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return an Array" do
|
27
|
+
expect(NvidiaSmi.gpus).to be_a(Array)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return an Array with one element per GPU" do
|
31
|
+
expect(NvidiaSmi.gpus.count).to eq(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return an Array of Struct::Gpu" do
|
35
|
+
expect(NvidiaSmi.gpus.first).to be_a(Struct::Gpu)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the GPUs index" do
|
39
|
+
expect(NvidiaSmi.gpus.first.index).to eq("0")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the GPUs pci bus" do
|
43
|
+
expect(NvidiaSmi.gpus.first.pci_bus).to eq("0x01")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return the GPUs model name" do
|
47
|
+
expect(NvidiaSmi.gpus.first.name).to eq("GeForce GTX 1060 3GB")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Not sure there really is a point in testing every value here...
|
51
|
+
|
52
|
+
end
|
53
|
+
|
5
54
|
end
|
6
55
|
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nvidia-smi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Cornuwel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bones
|
@@ -31,14 +31,15 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- History.txt
|
33
33
|
files:
|
34
|
+
- ".Rakefile.swp"
|
34
35
|
- ".bnsignore"
|
36
|
+
- ".gitignore"
|
35
37
|
- History.txt
|
36
38
|
- README.md
|
37
39
|
- Rakefile
|
38
40
|
- lib/nvidia-smi.rb
|
39
41
|
- spec/nvidia-smi_spec.rb
|
40
42
|
- spec/spec_helper.rb
|
41
|
-
- test/test_nvidia-smi.rb
|
42
43
|
- version.txt
|
43
44
|
homepage: https://github.com/cornuwel/nvidia-smi
|
44
45
|
licenses: []
|
@@ -65,5 +66,4 @@ rubygems_version: 2.5.1
|
|
65
66
|
signing_key:
|
66
67
|
specification_version: 4
|
67
68
|
summary: Get informations about the system's GPU(s), through nvidia-smi.
|
68
|
-
test_files:
|
69
|
-
- test/test_nvidia-smi.rb
|
69
|
+
test_files: []
|
data/test/test_nvidia-smi.rb
DELETED
File without changes
|