diff --git a/GPUmodules/GPUgui.py b/GPUmodules/GPUgui.py index e40b6a7..508ee12 100755 --- a/GPUmodules/GPUgui.py +++ b/GPUmodules/GPUgui.py @@ -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 @@ -17,7 +17,7 @@ along with this program. If not, see . """ __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' diff --git a/GPUmodules/GPUmodule.py b/GPUmodules/GPUmodule.py index 8cdf33b..07ce47b 100755 --- a/GPUmodules/GPUmodule.py +++ b/GPUmodules/GPUmodule.py @@ -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 @@ -18,7 +18,7 @@ along with this program. If not, see . """ __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' @@ -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 '' diff --git a/GPUmodules/__init__.py b/GPUmodules/__init__.py deleted file mode 100644 index babb526..0000000 --- a/GPUmodules/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part the amdgpu-util package -# -# Copyright (C) 2019 RueiKe -# -# 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from GPUmodules import GPUgui -from GPUmodules import GPUmodule -from GPUmodules import env diff --git a/GPUmodules/env.py b/GPUmodules/env.py index aca80b1..e08853a 100755 --- a/GPUmodules/env.py +++ b/GPUmodules/env.py @@ -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 @@ -18,7 +18,7 @@ along with this program. If not, see . """ __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' @@ -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 @@ -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: @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..30059b5 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.md +include LICENSE +include requirements.txt +include requirements-venv.txt diff --git a/README.md b/README.md index 230b98c..54acc53 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/amdgpu-chk b/amdgpu-chk index e23134d..40d8827 100755 --- a/amdgpu-chk +++ b/amdgpu-chk @@ -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 @@ -19,7 +19,7 @@ along with this program. If not, see . """ __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' diff --git a/amdgpu-ls b/amdgpu-ls index 3e1f292..8885b8c 100755 --- a/amdgpu-ls +++ b/amdgpu-ls @@ -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 @@ -26,7 +26,7 @@ along with this program. If not, see . """ __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' diff --git a/amdgpu-monitor b/amdgpu-monitor index da73510..f69db70 100755 --- a/amdgpu-monitor +++ b/amdgpu-monitor @@ -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 @@ -31,7 +31,7 @@ along with this program. If not, see . """ __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' @@ -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) diff --git a/amdgpu-pac b/amdgpu-pac index 855938a..8a1adc9 100755 --- a/amdgpu-pac +++ b/amdgpu-pac @@ -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 @@ -26,7 +26,7 @@ along with this program. If not, see . """ __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' @@ -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) diff --git a/amdgpu-plot b/amdgpu-plot index 3ac673c..c07dbe3 100755 --- a/amdgpu-plot +++ b/amdgpu-plot @@ -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 @@ -30,7 +30,7 @@ along with this program. If not, see . """ __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' @@ -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) diff --git a/setup.py b/setup.py index 0235a7e..9bb8887 100644 --- a/setup.py +++ b/setup.py @@ -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', @@ -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', @@ -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',