Whole file
wookayin/gpustat
The author described this change as “Fix python3 compatibility”. It counts as a record because the check below fails on the code as it stood at 7b11c487f and passes on d45fa7297, with nothing else changed between the two runs.
Projectwookayin/gpustat
Fix saved2017-03-04
Sharing licenceMIT · LICENSE
Change size+6 −6
What the code was meant to do, written into the code itself as a save note
Fix python3 compatibility
The change
| 163 | 163 | 'utilization.gpu', 'memory.used', 'memory.total') | |
| 164 | 164 | gpu_list = [] | |
| 165 | 165 | ||
| 166 | - | smi_output = check_output( | |
| 166 | + | smi_output = str(check_output( | |
| 167 | 167 | r'nvidia-smi --query-gpu={query_cols} --format=csv,noheader,nounits'.format( | |
| 168 | 168 | query_cols=','.join(gpu_query_columns) | |
| 169 | - | ), shell=True).decode().strip() | |
| 169 | + | ), shell=True).strip()) | |
| 170 | 170 | ||
| 171 | 171 | for line in smi_output.split('\n'): | |
| 172 | 172 | if not line: continue | |
| ⋯ | |||
| 183 | 183 | def running_processes(): | |
| 184 | 184 | # 1. collect all running GPU processes | |
| 185 | 185 | gpu_query_columns = ('gpu_uuid', 'pid', 'used_memory') | |
| 186 | - | smi_output = check_output( | |
| 186 | + | smi_output = str(check_output( | |
| 187 | 187 | r'nvidia-smi --query-compute-apps={query_cols} --format=csv,noheader,nounits'.format( | |
| 188 | 188 | query_cols=','.join(gpu_query_columns) | |
| 189 | - | ), shell=True).decode() | |
| 189 | + | ), shell=True).strip()) | |
| 190 | 190 | ||
| 191 | 191 | process_entries = [] | |
| 192 | 192 | for line in smi_output.split('\n'): | |
| ⋯ | |||
| 202 | 202 | ||
| 203 | 203 | # 2. map pid to username, etc. | |
| 204 | 204 | if pid_map: | |
| 205 | - | pid_output = check_output('ps -o {} -p {}'.format( | |
| 205 | + | pid_output = str(check_output('ps -o {} -p {}'.format( | |
| 206 | 206 | 'pid,user:16,comm', | |
| 207 | 207 | ','.join(map(str, pid_map.keys())) | |
| 208 | - | ), shell=True).decode().strip() | |
| 208 | + | ), shell=True).strip()) | |
| 209 | 209 | for line in pid_output.split('\n'): | |
| 210 | 210 | if (not line) or 'PID' in line: continue | |
| 211 | 211 | pid, user, comm = line.split()[:3] | |
The check that tells the two apart
fail→pass·test_gpustat.py::TestGPUStat::test_attributes_and_items
Check file test_gpustat.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it7b11c487f3f7db452cd46502c912792ef36739f4
Broken version dated2017-03-04
Modulegpustat
Units changedGPUStatCollection
Fingerprint4fe12aaab5afe757
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.