-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker_runner.py
More file actions
40 lines (30 loc) · 1.07 KB
/
worker_runner.py
File metadata and controls
40 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
Worker runner: reads a queue file and processes buckets.
Called by master.py for each GPU.
"""
import argparse
import json
import sys
import traceback
from worker import process_bucket
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--gpu", type=int, required=True)
parser.add_argument("--queue-file", type=str, required=True)
parser.add_argument("--no-upload", action="store_true")
args = parser.parse_args()
with open(args.queue_file) as f:
queue = json.load(f)
print(f"Worker GPU {args.gpu}: processing {len(queue)} buckets", flush=True)
for i, (dimension, bucket) in enumerate(queue):
bucket = tuple(bucket)
print(f"\n[{i+1}/{len(queue)}] {dimension} {bucket}", flush=True)
try:
process_bucket(dimension, bucket, args.gpu, upload=not args.no_upload)
except Exception as e:
print(f"FAILED: {e}", flush=True)
traceback.print_exc()
print(f"Worker GPU {args.gpu}: all done!", flush=True)
if __name__ == "__main__":
main()