Turns out that only one of the processes’ trackers has the attribute active_run
. I added a print(dir(tracker))
and got the following:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'finish', 'log', 'main_process_only', 'name', 'requires_logging_directory', 'store_init_configuration', 'tracker']
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'active_run', 'finish', 'log', 'main_process_only', 'name', 'requires_logging_directory', 'store_init_configuration', 'tracker']
After doing some more investigation it seems like there’s a main_process
and non-main_process
s. I changed my code to:
if accelerator.is_main_process:
info = tracker.active_run.to_dictionary()
with open(file=$PATH, mode="w") as f:
json.dump(obj=info, fp=f, indent=2)
and it works now.