compute_unit 0.2.1 → 0.3.0
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/CHANGELOG.md +7 -0
- data/lib/compute_unit/cpu.rb +2 -0
- data/lib/compute_unit/device.rb +3 -3
- data/lib/compute_unit/gpus/nvidia_gpu.rb +4 -2
- data/lib/compute_unit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc45e864245505b64cd82233ca7f8ad70d0d12ca1a976862ba46c80e66fefc8
|
4
|
+
data.tar.gz: 6903aff2b613ee6f88c41aa051e65404f31c8923bab2059323dfd27bc99cc5e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a971813c562bc8c29305f1fe3668f229b52bd018049d36879fcc943a935232e8d8bb34095e74643ca9d3da594796a4cdfdc33fe06b36a8501a75c0a330489cb3
|
7
|
+
data.tar.gz: bc17da953ab1904661c7037977c36b1dda69c7c4236c5854730743fa9332987a92ba3891e97052c4ee9361bea7a0b830a917235e15f1db75e8246b7835715a6e
|
data/CHANGELOG.md
CHANGED
data/lib/compute_unit/cpu.rb
CHANGED
@@ -7,6 +7,8 @@ module ComputeUnit
|
|
7
7
|
DEVICE_CLASS = '060000'
|
8
8
|
DEVICE_CLASS_NAME = 'CPU'
|
9
9
|
# @return [Array] - returns a list of device paths of all devices considered for display
|
10
|
+
alias name model
|
11
|
+
|
10
12
|
def self.devices
|
11
13
|
ComputeUnit::ComputeBase.devices.find_all do |device|
|
12
14
|
ComputeUnit::Device.device_class(device) == DEVICE_CLASS
|
data/lib/compute_unit/device.rb
CHANGED
@@ -10,7 +10,7 @@ module ComputeUnit
|
|
10
10
|
class Device
|
11
11
|
# We can supply a mock sysfs path in order to test with containers and other scenarios
|
12
12
|
SYSFS_DEVICES_PATH = File.join(ComputeUnit::SYSFS_PATH, 'bus', 'pci', 'devices')
|
13
|
-
|
13
|
+
PROC_PATH = ENV['PROC_PATH'] || '/proc'
|
14
14
|
attr_reader :device_class_id,
|
15
15
|
:device_id,
|
16
16
|
:device_vendor_id,
|
@@ -130,7 +130,7 @@ module ComputeUnit
|
|
130
130
|
rescue Errno::EINVAL, Errno::EPERM
|
131
131
|
default
|
132
132
|
rescue Errno::ENOENT
|
133
|
-
logger.
|
133
|
+
logger.debug("File #{path} does not exist, using defaults")
|
134
134
|
default
|
135
135
|
rescue Errno::EACCES
|
136
136
|
logger.fatal('run this command as root or with sudo, using default value')
|
@@ -271,7 +271,7 @@ module ComputeUnit
|
|
271
271
|
logger.fatal(e.message)
|
272
272
|
default
|
273
273
|
rescue Errno::ENOENT
|
274
|
-
logger.
|
274
|
+
logger.debug("File #{path} does not exist")
|
275
275
|
default
|
276
276
|
rescue Errno::EACCES
|
277
277
|
logger.fatal('Run this command as root or with sudo')
|
@@ -8,6 +8,7 @@ module ComputeUnit
|
|
8
8
|
MAKE = 'Nvidia'
|
9
9
|
SUBTYPE = 'nvidia'
|
10
10
|
NVIDIA_SMI = '/usr/bin/nvidia-smi'
|
11
|
+
NVIDIA_PROC_PATH = ENV['NVIDIA_PROC_PATH'] || File.join(ComputeUnit::Device::PROC_PATH, 'driver', 'nvidia', 'gpus')
|
11
12
|
|
12
13
|
def initialize(device_path, opts = {})
|
13
14
|
data = self.class.read_information_file(device_path).merge(opts)
|
@@ -159,7 +160,7 @@ module ComputeUnit
|
|
159
160
|
def information_file
|
160
161
|
@information_file ||= begin
|
161
162
|
device_name = File.basename(device_path)
|
162
|
-
File.join(
|
163
|
+
File.join(NVIDIA_PROC_PATH, device_name, 'information')
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
@@ -209,7 +210,8 @@ module ComputeUnit
|
|
209
210
|
# :device_minor=>"7"}
|
210
211
|
def self.read_information_file(device_path)
|
211
212
|
device_name = File.basename(device_path)
|
212
|
-
information_file =
|
213
|
+
information_file = File.join(NVIDIA_PROC_PATH, device_name, 'information')
|
214
|
+
|
213
215
|
File.open(information_file, 'r') do |file|
|
214
216
|
content = file.read
|
215
217
|
content.scan(/\n?([\w\s]*):\s+(.*)/).map { |key, value| [key.downcase.tr(' ', '_').to_sym, value] }.to_h
|
data/lib/compute_unit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compute_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Osman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opencl_ruby_ffi
|