nvidia-smi 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93f2f96de404d5617142645bb68d29c262cff38e
4
- data.tar.gz: 7dcc98871d3cb625dedfd420b5413e3d77a99b69
3
+ metadata.gz: 59d2f12427c81967e6105f1ba8ab95d89ce2dae7
4
+ data.tar.gz: 92bfb4cb4e5e9956a4882aa37b9b6d7e208ba67a
5
5
  SHA512:
6
- metadata.gz: 73eda3ea2a7da36372a9e913f9cc67ed3f24473dafc268e751715c77ec8efa60107f7d3a0c5570fdb8aee43713e6f8524a215f65def029587444409c4e131a13
7
- data.tar.gz: 259172d4d5a5d249a17bf9a45da9d0e77c82a8cdd5f6b346c45378d21b1f888c016413bde3bf34080b21b7446cae2b48612b715b72a51d04190b1a975fccf6ef
6
+ metadata.gz: 8965df2a060fe90da32e74e9ea80d3cb54373941744e82f4feb4702e3eb3b1bfa472648a5d152edbe5d62a416ee2fb481fc24f8897a5b42b0cf98bddbffd39ca
7
+ data.tar.gz: abeb56805823fb128d91cb3ebc8b8b88ac6587cbb7ce0bf007825e2f8c5d3726e6ad625b7aa1c22e6e410365a8286b50282c8bd5571c79dfe010fb32eaa19d8c
Binary file
@@ -0,0 +1 @@
1
+ pkg
@@ -1,3 +1,9 @@
1
+ == 0.1.1 / 2017-11-06
2
+
3
+ * No new features
4
+ * Added comments for rdoc
5
+ * Added specs
6
+
1
7
  == 0.1.0 / 2017-11-05
2
8
 
3
9
  * Very basic functionality
data/README.md CHANGED
@@ -1,10 +1,16 @@
1
+ [![Gem Version](https://badge.fury.io/rb/nvidia-smi.svg)](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 informations about the system's GPU(s), through nvidia-smi.
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 FIXME Julien Cornuwel
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
@@ -5,8 +5,8 @@ rescue LoadError
5
5
  abort '### Please install the "bones" gem ###'
6
6
  end
7
7
 
8
- task :default => 'test:run'
9
- task 'gem:release' => 'test:run'
8
+ task :default => 'spec'
9
+ task 'gem:release' => 'spec'
10
10
 
11
11
  Bones {
12
12
  name 'nvidia-smi'
@@ -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
- data = `nvidia-smi --query-gpu=#{@@nvidia_keys.join(',')} --format=csv,noheader`.each_line do |line|
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
 
@@ -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
 
@@ -1 +1 @@
1
- 0.1.0
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.0
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-05 00:00:00.000000000 Z
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: []
File without changes