Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GPUmodules/GPUgui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
""" amdgpu-utils: GPUgui module to support gui in amdgpu-utils.

Copyright (C) 2020 RueiKe
Copyright (C) 2020 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -17,7 +17,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2020 RueiKe'
__copyright__ = 'Copyright (C) 2020 RicksLab'
__credits__ = ['@berturion - Testing and Verification']
__license__ = 'GNU General Public License'
__program_name__ = 'amdgpu-utils'
Expand Down
7 changes: 5 additions & 2 deletions GPUmodules/GPUmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""GPUmodules - Classes to represent GPUs and sets of GPUs used in amdgpu-utils.


Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation',
'Keith Myers - Testing, Debug, Verification of NV Capability']
__license__ = 'GNU General Public License'
Expand Down Expand Up @@ -696,6 +696,9 @@ def read_pciid_model(self) -> str:
:return: GPU model name
"""
LOGGER.debug('Logger active in module')
if not env.GUT_CONST.sys_pciid:
print('Error: Can not access system pci.ids file [{}]'.format(env.GUT_CONST.sys_pciid))
return ''
if not os.path.isfile(env.GUT_CONST.sys_pciid):
print('Error: Can not access system pci.ids file [{}]'.format(env.GUT_CONST.sys_pciid))
return ''
Expand Down
19 changes: 0 additions & 19 deletions GPUmodules/__init__.py

This file was deleted.

48 changes: 31 additions & 17 deletions GPUmodules/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""env.py - sets environment for amdgpu-utils and establishes global variables


Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, and Verification']
__license__ = 'GNU General Public License'
__program_name__ = 'amdgpu-utils'
Expand Down Expand Up @@ -74,22 +74,34 @@ class GutConst:
'VAL_ITEM': re.compile(r'.*_val$'),
'GPUMEMTYPE': re.compile(r'^mem_(gtt|vram)_.*')}

_sys_pciid_list = ['/usr/share/misc/pci.ids', '/usr/share/hwdata/pci.ids']
_local_icon_list = ['{}/.local/share/ricks-amdgpu-utils/icons'.format(str(Path.home())),
'/usr/share/ricks-amdgpu-utils/icons']
featuremask = '/sys/module/amdgpu/parameters/ppfeaturemask'
card_root = '/sys/class/drm/'
hwmon_sub = 'hwmon/hwmon'

def __init__(self):
self.args = None
self.repository_module_path = os.path.dirname(str(Path(__file__).resolve()))
self.repository_path = os.path.join(self.repository_module_path, '..')
self.dist_share = '/usr/share/ricks-amdgpu-utils/'
self.sys_pciid = '/usr/share/misc/pci.ids'
self.sys_pciid_list: List[str] = ['/usr/share/misc/pci.ids', '/usr/share/hwdata/pci.ids']
self.dist_icons = os.path.join(self.dist_share, 'icons')
if os.path.isdir(self.dist_icons):
self.icon_path = self.dist_icons
else:
self.icon_path = os.path.join(self.repository_path, 'icons')
self.featuremask = '/sys/module/amdgpu/parameters/ppfeaturemask'

# Set pciid Path
self.sys_pciid = None
for try_pciid_path in GutConst._sys_pciid_list:
if os.path.isfile(try_pciid_path):
self.sys_pciid = try_pciid_path
break

# Set Icon Path
self._local_icon_list.append(os.path.join(self.repository_path, 'icons'))
self.icon_path = None
for try_icon_path in GutConst._local_icon_list:
if os.path.isdir(try_icon_path):
self.icon_path = try_icon_path
break

self.distro: Dict[str, Union[str, None]] = {'Distributor': None, 'Description': None}
self.card_root = '/sys/class/drm/'
self.hwmon_sub = 'hwmon/hwmon'
self.amdfeaturemask = ''
self.log_file_ptr = ''
# From args
Expand Down Expand Up @@ -153,6 +165,8 @@ def set_args(self, args) -> None:
LOGGER.addHandler(file_handler)
LOGGER.debug('Command line arguments:\n %s', args)
LOGGER.debug('Local TZ: %s', self.LTZ)
LOGGER.debug('pciid path set to: %s', self.sys_pciid)
LOGGER.debug('Icon path set to: %s', self.icon_path)

@staticmethod
def now(ltz: bool = False) -> datetime:
Expand Down Expand Up @@ -253,10 +267,10 @@ def check_env(self) -> int:
print('OS command [lsb_release] executable not found.')

# Check which pci-ids file is to be used
for test_sys_pciid in self.sys_pciid_list:
if os.path.isfile(test_sys_pciid):
self.sys_pciid = test_sys_pciid
break
#for test_sys_pciid in self.sys_pciid_list:
#if os.path.isfile(test_sys_pciid):
#self.sys_pciid = test_sys_pciid
#break

# Check access/paths to system commands
command_access_fail = False
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md
include LICENSE
include requirements.txt
include requirements-venv.txt
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# amdgpu-utils
A set of utilities for monitoring AMD GPU performance and modifying control settings.

In order to use any of these utilities, you must have the *amdgpu* open source driver
package installed. You also must first set your Linux machine to boot with
amdgpu.ppfeaturemask=0xfffd7fff. This can be accomplished by adding
amdgpu.ppfeaturemask=0xfffd7fff to the GRUB_CMDLINE_LINUX_DEFAULT value in
/etc/default/grub and executing *sudo update-grub*
In order to get maximum capability of these utilities, you should be running with a kernel that
provides support of the GPUs you have installed. If using AMD GPUs, installing the latest amdgpu
driver package or the latest ROCm release, may provide additional capabilities. If you have Nvidia
GPUs installed, you should have `nvidia.smi` installed in order for the utility reading of the cards
to be possible. Writing to GPUs is currently only possible for AMD GPUs, and only with compatible
cards and with the the AMD ppfeaturemask set to 0xfffd7fff. This can be accomplished by adding
`amdgpu.ppfeaturemask=0xfffd7fff` to the `GRUB_CMDLINE_LINUX_DEFAULT` value in
`/etc/default/grub` and executing `sudo update-grub`

Check out the [User Guide](docs/USER_GUIDE.md)!

Download latest official release: [v3.2.0](https://github.com/Ricks-Lab/amdgpu-utils/releases/tag/v3.2.0)
or install the latest package from [PyPI](https://pypi.org/project/ricks-amdgpu-utils/) with the following
command:
```shell script
pip3 install ricks-amdgpu-utils
```

## amdgpu-chk
This utility verifies if the environment is compatible with *amdgpu-util*s.
Expand Down Expand Up @@ -63,12 +71,14 @@ terminal where you executed *amdgpu-pac*. The *--no_fan* option can be used to e
fan details from the utility. The *--force_write* option can be used to force all configuration
parameters to be written to the GPU. The default behavior is to only write changes.

#### New in this Development Branch
#### New in this Development Branch - V3.3.0
* Display card path details in logger whenever card path exists.
* Implemented read capabilities for Nvidia. Now supported by all utilities except pac.
* Added APU type and tuned parameters read/displayed for AMD APU integrated GPU.
* Read generic pcie sensors for all types of GPUs.
* Improved lspci search by using a no-shell call and using compiled regex.
* Implement PyPI package for easy installation.
* More robust handling of missing Icon and PCIID files.

## Development Plans
* Optimize plot utilities for performance.
Expand Down
4 changes: 2 additions & 2 deletions amdgpu-chk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This utility verifies if the environment is compatible with amdgpu-utils.

Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation']
__license__ = 'GNU General Public License'
__program_name__ = 'amdgpu-chk'
Expand Down
4 changes: 2 additions & 2 deletions amdgpu-ls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
of basic parameters. The *--ppm* option is used to output the table of available
power/performance modes instead of basic parameters.

Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -26,7 +26,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation',
'Keith Myers - Testing, Debug, Verification of NV Capability']
__license__ = 'GNU General Public License'
Expand Down
14 changes: 8 additions & 6 deletions amdgpu-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
over running both tools as a single read of the GPUs is used to update both displays.
The *--ltz* option results in the use of local time instead of UTC.

Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -31,7 +31,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation',
'Keith Myers - Testing, Debug, Verification of NV Capability']
__license__ = 'GNU General Public License'
Expand Down Expand Up @@ -105,10 +105,12 @@ class MonitorWindow(Gtk.Window):
self.set_border_width(0)
GPUgui.GuiProps.set_style()

icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-monitor.icon.png')
LOGGER.debug('Icon file: [%s]', icon_file)
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)
if env.GUT_CONST.icon_path:
icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-monitor.icon.png')
LOGGER.debug('Icon file: [%s]', icon_file)
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)

grid = Gtk.Grid()
self.add(grid)

Expand Down
12 changes: 7 additions & 5 deletions amdgpu-pac
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
fan details from the utility. The *--force_write* option can be used to force all configuration
parameters to be written to the GPU. The default behavior is to only write changes.

Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -26,7 +26,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation']
__license__ = 'GNU General Public License'
__program_name__ = 'amdgpu-pac'
Expand Down Expand Up @@ -78,9 +78,11 @@ class PACWindow(Gtk.Window):
self.set_border_width(0)
GPUgui.GuiProps.set_style()

icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-pac.icon.png')
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)
if env.GUT_CONST.icon_path:
icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-pac.icon.png')
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)

grid = Gtk.Grid()
self.add(grid)

Expand Down
11 changes: 6 additions & 5 deletions amdgpu-plot
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*amdgpu-monitor* utility should be used instead of both utilities in order reduce
data reads by a factor of 2.

Copyright (C) 2019 RueiKe
Copyright (C) 2019 RicksLab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -30,7 +30,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = 'RueiKe'
__copyright__ = 'Copyright (C) 2019 RueiKe'
__copyright__ = 'Copyright (C) 2019 RicksLab'
__credits__ = ['Craig Echt - Testing, Debug, Verification, and Documentation',
'Keith Myers - Testing, Debug, Verification of NV Capability']
__license__ = 'GNU General Public License'
Expand Down Expand Up @@ -322,9 +322,10 @@ class GPUPlotWindow(Gtk.Window):
self.set_border_width(0)
GPUgui.GuiProps.set_style()

icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-plot.icon.png')
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)
if env.GUT_CONST.icon_path:
icon_file = os.path.join(env.GUT_CONST.icon_path, 'amdgpu-plot.icon.png')
if os.path.isfile(icon_file):
self.set_icon_from_file(icon_file)

grid = Gtk.Grid()
self.add(grid)
Expand Down
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


setup(name='ricks-amdgpu-utils',
version='3.2.0',
version='3.3.0',
description='Ricks-Lab AMD GPU Utilities',
long_description='A set of utilities for monitoring AMD GPU performance and modifying control settings.',
author='RueiKe',
Expand All @@ -21,6 +21,11 @@
scripts=['amdgpu-chk', 'amdgpu-ls', 'amdgpu-monitor', 'amdgpu-pac', 'amdgpu-plot'],
license='GPL-3',
python_requires='>=3.6',
classifiers=['Development Status :: 5 - Production/Stable',
'Operating System :: POSIX',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Topic :: System :: Monitoring'],
install_requires=['cycler>=0.10.0',
'kiwisolver>=1.1.0',
'matplotlib>=3.1.3',
Expand All @@ -35,7 +40,7 @@
data_files=[('share/ricks-amdgpu-utils/icons', ['icons/amdgpu-monitor.icon.png',
'icons/amdgpu-pac.icon.png',
'icons/amdgpu-plot.icon.png']),
('share/ricks-amdgpu-utils/doc', ['README.md']),
('share/ricks-amdgpu-utils/doc', ['README.md', 'LICENSE']),
('share/man/man1', ['man/amdgpu-chk.1',
'man/amdgpu-ls.1',
'man/amdgpu-monitor.1',
Expand Down