Ricks-Lab / gpu-utils

A set of utilities for monitoring and customizing GPU performance
GNU General Public License v3.0
136 stars 23 forks source link

PCIID encoding issue when running amdgpu-ls #64

Closed CH3CN closed 4 years ago

CH3CN commented 4 years ago

Thank you for creating this project. I am using Gentoo instead of Ubuntu and I was running into an issue when using amdgpu-ls.

(amdgpu-utils-env) gentoo /home/ch3cn/amdgpu-utils-master # ./amdgpu-ls Package addon [clinfo] executable not found. Use sudo apt-get install clinfo to install OS command [dpkg] executable not found. OS Command [clinfo] not found. Use sudo apt-get install clinfo to install Detected GPUs: INTEL: 1, AMD: 1 Command None not found. Can not determine amdgpu version. AMD: Wattman features enabled: 0xfffd7fff Traceback (most recent call last): File "./amdgpu-ls", line 141, in main() File "./amdgpu-ls", line 111, in main gpu_list.read_gpu_sensor_data(data_type='All') File "/home/ch3cn/amdgpu-utils-master/GPUmodules/GPUmodule.py", line 1512, in read_gpu_sensor_data v.read_gpu_sensor_data(data_type) File "/home/ch3cn/amdgpu-utils-master/GPUmodules/GPUmodule.py", line 940, in read_gpu_sensor_data self.set_params_value(param, rdata) File "/home/ch3cn/amdgpu-utils-master/GPUmodules/GPUmodule.py", line 334, in set_params_value self.prm.model_device_decode = self.read_pciid_model() File "/home/ch3cn/amdgpu-utils-master/GPUmodules/GPUmodule.py", line 353, in read_pciid_model for line_item in pci_id_file_ptr: File "/usr/lib/python-exec/python3.6/../../../lib64/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4514: ordinal not in range(128)

I checked the encoding of the pci.ids file:

(amdgpu-utils-env) gentoo /home/ch3cn/amdgpu-utils-master # file -i /usr/share/misc/pci.ids /usr/share/misc/pci.ids: text/plain; charset=utf-8

I updated line 350 in GPUmodule.py to include the utf8 encoding:

with open(env.GUT_CONST.sys_pciid, 'r', encoding='utf8') as pci_id_file_ptr:

Now amdgpu-ls works:

(amdgpu-utils-env) gentoo /home/ch3cn/amdgpu-utils-master # ./amdgpu-ls
Package addon [clinfo] executable not found. Use sudo apt-get install clinfo to install OS command [dpkg] executable not found. OS Command [clinfo] not found. Use sudo apt-get install clinfo to install Detected GPUs: INTEL: 1, AMD: 1 Command None not found. Can not determine amdgpu version. AMD: Wattman features enabled: 0xfffd7fff 2 total GPUs, 1 rw, 0 r-only, 0 w-only

Card Number: 0 Vendor: INTEL Readable: False Writable: False Compute: True Card Model: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) PCIe ID: 00:02.0 Driver: i915 Card Path: /sys/class/drm/card0/device`

Card Number: 1 Vendor: AMD Readable: True Writable: True Compute: True GPU UID: Device ID: {'vendor': '0x1002', 'device': '0x67ef', 'subsystem_vendor': '0x1458', 'subsystem_device': '0x22de'} Decoded Device ID: Baffin [Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X] Card Model: Advanced Micro Devices, Inc. [AMD/ATI] Baffin [Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X] (rev cf) Display Card Model: Baffin [Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X] PCIe ID: 01:00.0 Link Speed: 2.5 GT/s Link Width: 8 ################################################## Driver: amdgpu vBIOS Version: xxx-xxx-xxx Compute Platform: None GPU Frequency/Voltage Control Type: 1 HWmon: /sys/class/drm/card1/device/hwmon/hwmon2 Card Path: /sys/class/drm/card1/device ################################################## Current Power (W): 7.2 Power Cap (W): 48.0 Power Cap Range (W): [0, 72] Fan Enable: 0 Fan PWM Mode: [2, 'Dynamic'] Fan Target Speed (rpm): 933 Current Fan Speed (rpm): 933 Current Fan PWM (%): 31 Fan Speed Range (rpm): [0, 4600] Fan PWM Range (%): [0, 100] ################################################## Current GPU Loading (%): 0 Current Memory Loading (%): 3 Current Temps (C): {'edge': 22.0} Critical Temp (C): 94.0 Current Voltages (V): {'vddgfx': 800} Vddc Range: ['800mV', '1150mV'] Current Clk Frequencies (MHz): {'sclk': 214.0, 'mclk': 300.0} Current SCLK P-State: [0, '214Mhz'] SCLK Range: ['214MHz', '1800MHz'] Current MCLK P-State: [0, '300Mhz'] MCLK Range: ['300MHz', '2000MHz'] Power Profile Mode: 1-3D_FULL_SCREEN Power DPM Force Performance Level: auto

I'm not sure why the encoding has to be explicitly stated and I'm not knowledgeable at all in Python to find out.

Ricks-Lab commented 4 years ago

Thanks for raising the issue. I have made the change and verified that it still works on my Ubuntu system.