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.

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

163163 'utilization.gpu', 'memory.used', 'memory.total')
164164 gpu_list = []
165165
166- smi_output = check_output(
166+ smi_output = str(check_output(
167167 r'nvidia-smi --query-gpu={query_cols} --format=csv,noheader,nounits'.format(
168168 query_cols=','.join(gpu_query_columns)
169- ), shell=True).decode().strip()
169+ ), shell=True).strip())
170170
171171 for line in smi_output.split('\n'):
172172 if not line: continue
183183 def running_processes():
184184 # 1. collect all running GPU processes
185185 gpu_query_columns = ('gpu_uuid', 'pid', 'used_memory')
186- smi_output = check_output(
186+ smi_output = str(check_output(
187187 r'nvidia-smi --query-compute-apps={query_cols} --format=csv,noheader,nounits'.format(
188188 query_cols=','.join(gpu_query_columns)
189- ), shell=True).decode()
189+ ), shell=True).strip())
190190
191191 process_entries = []
192192 for line in smi_output.split('\n'):
202202
203203 # 2. map pid to username, etc.
204204 if pid_map:
205- pid_output = check_output('ps -o {} -p {}'.format(
205+ pid_output = str(check_output('ps -o {} -p {}'.format(
206206 'pid,user:16,comm',
207207 ','.join(map(str, pid_map.keys()))
208- ), shell=True).decode().strip()
208+ ), shell=True).strip())
209209 for line in pid_output.split('\n'):
210210 if (not line) or 'PID' in line: continue
211211 pid, user, comm = line.split()[:3]

The check that tells the two apart

failpass·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.