Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force argument in print function #5

Open
iksooman opened this issue Jan 4, 2024 · 1 comment
Open

force argument in print function #5

iksooman opened this issue Jan 4, 2024 · 1 comment

Comments

@iksooman
Copy link

iksooman commented Jan 4, 2024

Thanks for sharing your code!

I'm trying to test your code, but I got an error like:

Traceback (most recent call last):
  File "C:\Users\admin\PreNAS\supernet_train.py", line 463, in <module>
    main(args)
  File "C:\Users\admin\PreNAS\supernet_train.py", line 404, in main
    train_stats = train_one_epoch(
  File "C:\Users\admin\PreNAS\supernet_engine.py", line 187, in train_one_epoch
    print("DEBUG:train {}".format(config), force=print2file)
TypeError: 'force' is an invalid keyword argument for print()

Could you give me an idea for resolving this error?

@drcege
Copy link

drcege commented Jul 17, 2024

Did you skip the distributed setup? The print function is replaced here:

PreNAS/lib/utils.py

Lines 165 to 177 in 0050c7a

def setup_for_distributed(is_master):
"""
This function disables printing when not in master process
"""
import builtins as __builtin__
builtin_print = __builtin__.print
def print(*args, **kwargs):
force = kwargs.pop('force', False)
if is_master or force:
builtin_print(*args, **kwargs)
__builtin__.print = print

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants