amdgpu_fan 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -8
- data/lib/amdgpu_fan_cli.rb +54 -11
- data/lib/amdgpu_service.rb +23 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8bd1ed519a47f577ba017c94f03ac02101767434796821120aef3f9e12d9ba9
|
4
|
+
data.tar.gz: 6d55c0d1c45d076d1409318332fade5d9038c8f4e64b86d8af2cb2d5eeb016df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba9441882e19a730fe7863ac49ac196d6ac6b6ed4f55a1f086d2467c122cb58b7e57fb3dc27d0bfbddcaba9344a89992b59fce9c1f52edb44feb54e9a718b97
|
7
|
+
data.tar.gz: 75b810c93258bbb39b2973f97e029cd602d70a61314da9e08af1a13fcaea5ec2ea7067e424aa0a3358d5a9b1863937cefa3a095897214f6ca8f0453757fd5250
|
data/README.md
CHANGED
@@ -1,15 +1,34 @@
|
|
1
1
|
# amdgpu-fan-rb
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/HarlemSquirrel/amdgpu-fan-rb.svg?branch=master)](https://travis-ci.org/HarlemSquirrel/amdgpu-fan-rb)
|
4
|
+
|
3
5
|
A Ruby CLI to read and set the fan speed for AMD Radeon graphics cards running on the AMDGPU Linux driver.
|
4
6
|
|
5
7
|
See https://wiki.archlinux.org/index.php/Fan_speed_control#AMDGPU_sysfs_fan_control
|
6
8
|
|
7
|
-
##
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
The `amdgpu_fan` CLI command can be installed from [RubyGems](https://rubygems.org/gems/amdgpu_fan) or easily run from the source code.
|
12
|
+
|
13
|
+
### From RubyGems
|
8
14
|
|
9
15
|
```
|
10
|
-
|
16
|
+
gem install amdgpu_fan
|
17
|
+
```
|
18
|
+
|
19
|
+
### From Source
|
11
20
|
|
12
|
-
|
21
|
+
```
|
22
|
+
➤ git clone https://github.com/HarlemSquirrel/amdgpu-fan-rb.git
|
23
|
+
➤ cd amdgpu-fan-rb
|
24
|
+
➤ bundle install
|
25
|
+
➤ bin/amdgpu_fan
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```
|
31
|
+
➤ amdgpu_fan help
|
13
32
|
Commands:
|
14
33
|
amdgpu_fan auto # Set mode to automatic (requires sudo)
|
15
34
|
amdgpu_fan help [COMMAND] # Describe available commands or one specific command
|
@@ -17,17 +36,25 @@ Commands:
|
|
17
36
|
amdgpu_fan status # View device info, current fan speed, and temperature
|
18
37
|
amdgpu_fan watch [SECONDS] # Watch current fan speed, and temperature refreshed every n seconds
|
19
38
|
|
20
|
-
➤
|
39
|
+
➤ amdgpu_fan status
|
21
40
|
📺 GPU: AMD Radeon (TM) R9 Fury Series
|
22
41
|
📄 vBIOS: 113-C8800100-102
|
23
42
|
🌀 Fan: auto mode running at 48% ~ 1828 rpm
|
24
43
|
🌡 Temp: 28.0°C
|
25
44
|
⚡ Power: 19.26 / 300.0 Watts
|
45
|
+
|
46
|
+
➤ bin/amdgpu_fan watch 3
|
47
|
+
Watching Advanced Micro Devices, Inc. [AMD/ATI] Radeon R9 FURY X / NANO every 3 second(s)...
|
48
|
+
<Press Ctrl-C to exit>
|
49
|
+
2019-05-10 20:36:01 - Clock: 512Mhz Core, 500Mhz Memory, Fan: 1838 rpm [||| ]27%, Load: [||| ]28%, Power: 15.12 W, Temp: 28.0°C
|
50
|
+
2019-05-10 20:36:05 - Clock: 300Mhz Core, 500Mhz Memory, Fan: 1837 rpm [||||| ]49%, Load: [ ]0%, Power: 16.18 W, Temp: 29.0°C
|
51
|
+
2019-05-10 20:36:09 - Clock: 512Mhz Core, 500Mhz Memory, Fan: 1837 rpm [||||| ]49%, Load: [ ]0%, Power: 15.11 W, Temp: 28.0°C
|
52
|
+
^C
|
53
|
+
And now the watch is ended.
|
26
54
|
```
|
27
55
|
|
28
56
|
## Dependencies
|
29
57
|
|
30
|
-
- Ruby
|
31
|
-
-
|
32
|
-
-
|
33
|
-
- lspci (included with most Linux distributions)
|
58
|
+
- [Ruby](https://www.ruby-lang.org) with [Bundler](https://bundler.io)
|
59
|
+
- [Thor](http://whatisthor.com/) (installed with `bundle install`)
|
60
|
+
- [`lspci`](https://linux.die.net/man/8/lspci) (included with most Linux distributions)
|
data/lib/amdgpu_fan_cli.rb
CHANGED
@@ -4,12 +4,19 @@ require_relative '../config/environment'
|
|
4
4
|
|
5
5
|
# The main class
|
6
6
|
class AmdgpuFanCli < Thor
|
7
|
-
desc 'auto', 'Set mode to automatic (requires sudo)'
|
7
|
+
desc 'auto', 'Set fan mode to automatic (requires sudo)'
|
8
8
|
def auto
|
9
9
|
amdgpu_service.set_fan_mode! :auto
|
10
10
|
puts fan_status
|
11
11
|
end
|
12
12
|
|
13
|
+
desc 'connectors', 'View the status of the display connectors'
|
14
|
+
def connectors
|
15
|
+
amdgpu_service.connectors_status.each do |connector,status|
|
16
|
+
puts "#{connector}: #{status}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
13
20
|
desc 'set PERCENTAGE', 'Set fan speed to PERCENTAGE (requires sudo)'
|
14
21
|
def set(percentage)
|
15
22
|
return puts "Invalid percentage" unless (0..100).cover?(percentage.to_i)
|
@@ -23,14 +30,15 @@ class AmdgpuFanCli < Thor
|
|
23
30
|
|
24
31
|
desc 'status', 'View device info, current fan speed, and temperature'
|
25
32
|
def status
|
26
|
-
|
27
|
-
|
33
|
+
puts radeon_logo,
|
34
|
+
"📺\tGPU: #{amdgpu_service.name}",
|
28
35
|
"📄\tvBIOS: #{amdgpu_service.vbios_version}",
|
36
|
+
clock_status,
|
29
37
|
fan_status,
|
30
38
|
"🌡\tTemp: #{amdgpu_service.temperature}°C",
|
31
39
|
"⚡\tPower: #{amdgpu_service.power_dpm_state} mode using " \
|
32
40
|
"#{amdgpu_service.power_draw} / #{amdgpu_service.power_max} Watts",
|
33
|
-
"⚖\tLoad: #{amdgpu_service.busy_percent}
|
41
|
+
"⚖\tLoad: #{percent_meter amdgpu_service.busy_percent, 20}"
|
34
42
|
end
|
35
43
|
|
36
44
|
desc 'watch [SECONDS]', 'Watch fan speed, load, power, and temperature ' \
|
@@ -42,26 +50,56 @@ class AmdgpuFanCli < Thor
|
|
42
50
|
' <Press Ctrl-C to exit>'
|
43
51
|
|
44
52
|
trap "SIGINT" do
|
45
|
-
puts
|
53
|
+
puts "\nAnd now the watch is ended."
|
46
54
|
exit 0
|
47
55
|
end
|
48
56
|
|
49
57
|
loop do
|
50
|
-
puts "#{Time.now.strftime("%F %T")} " \
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
58
|
+
puts "#{Time.now.strftime("%F %T")} - " \
|
59
|
+
"Clock: #{amdgpu_service.core_clock} Core, #{amdgpu_service.memory_clock} Memory,\t" \
|
60
|
+
"Fan: #{amdgpu_service.fan_speed_rpm} rpm #{percent_meter amdgpu_service.fan_speed_percent},\t" \
|
61
|
+
"Load: #{percent_meter amdgpu_service.busy_percent},\t" \
|
62
|
+
"Power: #{amdgpu_service.power_draw} W,\t" \
|
54
63
|
"Temp: #{amdgpu_service.temperature}°C "
|
55
64
|
sleep seconds.to_i
|
56
65
|
end
|
57
66
|
end
|
58
67
|
|
68
|
+
desc 'watch_csv [SECONDS]', 'Watch stats in CSV format ' \
|
69
|
+
'refreshed every n seconds defaulting to 1 second'
|
70
|
+
def watch_csv(seconds=1)
|
71
|
+
return puts "Seconds must be from 1 to 600" unless (1..600).cover?(seconds.to_i)
|
72
|
+
|
73
|
+
puts 'Timestamp, Core Clock (Mhz),Memory Clock (Mhz),Fan speed (rpm), '\
|
74
|
+
'Load (%),Power (Watts),Temp (°C)'
|
75
|
+
|
76
|
+
trap "SIGINT" do
|
77
|
+
exit 0
|
78
|
+
end
|
79
|
+
|
80
|
+
loop do
|
81
|
+
puts [Time.now.strftime("%F %T"),
|
82
|
+
amdgpu_service.core_clock,
|
83
|
+
amdgpu_service.memory_clock,
|
84
|
+
amdgpu_service.fan_speed_rpm,
|
85
|
+
amdgpu_service.busy_percent,
|
86
|
+
amdgpu_service.power_draw,
|
87
|
+
amdgpu_service.temperature].join(',')
|
88
|
+
sleep seconds.to_i
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
59
92
|
private
|
60
93
|
|
61
94
|
def amdgpu_service
|
62
95
|
@amdgpu_service ||= AmdgpuService.new
|
63
96
|
end
|
64
97
|
|
98
|
+
def clock_status
|
99
|
+
"⏰\tClocks: #{amdgpu_service.core_clock} Core, " \
|
100
|
+
"#{amdgpu_service.memory_clock} Memory"
|
101
|
+
end
|
102
|
+
|
65
103
|
def current_time
|
66
104
|
Time.now.strftime("%F %T")
|
67
105
|
end
|
@@ -71,7 +109,12 @@ class AmdgpuFanCli < Thor
|
|
71
109
|
"#{amdgpu_service.fan_speed_percent}% ~ #{amdgpu_service.fan_speed_rpm} rpm"
|
72
110
|
end
|
73
111
|
|
74
|
-
def
|
75
|
-
|
112
|
+
def percent_meter(percent, length = 10)
|
113
|
+
progress_bar_count = (length * percent.to_f / 100).round
|
114
|
+
"[#{'|' * progress_bar_count}#{' ' * (length - progress_bar_count)}]#{percent}%"
|
115
|
+
end
|
116
|
+
|
117
|
+
def radeon_logo
|
118
|
+
File.read(File.join(__dir__, '../lib/radeon_r_black_red_100x100.ascii'))
|
76
119
|
end
|
77
120
|
end
|
data/lib/amdgpu_service.rb
CHANGED
@@ -20,6 +20,16 @@ class AmdgpuService
|
|
20
20
|
File.read("#{base_card_folder}/gpu_busy_percent").strip
|
21
21
|
end
|
22
22
|
|
23
|
+
def connectors_status
|
24
|
+
connectors_files.each_with_object({}) do |f, connectors|
|
25
|
+
connectors[f.slice(/(?<=card0-)(\w|-)+/)] = File.read(f).strip
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def core_clock
|
30
|
+
clock_from_pp_file "/sys/class/drm/card#{card_num}/device/pp_dpm_sclk"
|
31
|
+
end
|
32
|
+
|
23
33
|
def fan_mode
|
24
34
|
FAN_MODES[File.read(fan_mode_file).strip] || 'unknown'
|
25
35
|
end
|
@@ -40,6 +50,10 @@ class AmdgpuService
|
|
40
50
|
File.read(fan_input_file).strip
|
41
51
|
end
|
42
52
|
|
53
|
+
def memory_clock
|
54
|
+
clock_from_pp_file "/sys/class/drm/card#{card_num}/device/pp_dpm_mclk"
|
55
|
+
end
|
56
|
+
|
43
57
|
def name
|
44
58
|
lspci_subsystem.split(': ')[1].strip
|
45
59
|
end
|
@@ -84,6 +98,14 @@ class AmdgpuService
|
|
84
98
|
@base_card_folder ||= "#{BASE_FOLDER}/card#{card_num}/device"
|
85
99
|
end
|
86
100
|
|
101
|
+
def clock_from_pp_file(file)
|
102
|
+
File.read(file).slice /\w+(?= \*)/
|
103
|
+
end
|
104
|
+
|
105
|
+
def connectors_files
|
106
|
+
@connectors_files ||= Dir["/sys/class/drm/card#{card_num}*/status"].sort
|
107
|
+
end
|
108
|
+
|
87
109
|
def fan_input_file
|
88
110
|
@fan_input_file ||= Dir.glob("#{base_card_folder}/**/fan1_input").first
|
89
111
|
end
|
@@ -113,7 +135,7 @@ class AmdgpuService
|
|
113
135
|
end
|
114
136
|
|
115
137
|
def power_max_file
|
116
|
-
@
|
138
|
+
@power_max_file ||= Dir.glob("#{base_card_folder}/**/power1_cap").first
|
117
139
|
end
|
118
140
|
|
119
141
|
def power_raw_to_watts(raw_string)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amdgpu_fan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McCormack
|
@@ -42,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
|
46
|
-
rubygems_version: 2.7.7
|
45
|
+
rubygems_version: 3.0.3
|
47
46
|
signing_key:
|
48
47
|
specification_version: 4
|
49
48
|
summary: A CLI to view and set fan speeds for AMD graphics cards running on the open
|