From c88ae0069238c4cb86eb8b64a06ccf1c13e5307b Mon Sep 17 00:00:00 2001 From: yousoumar Date: Mon, 10 Feb 2025 10:46:10 +0000 Subject: [PATCH] fix: replace stderr with stdout for download messages in hub.py (#146475) This PR addresses an issue where download logs in `hub.py` are sent to `stderr` instead of `stdout`. Hence, when running models with workers, these messages are incorrectly categorized as errors, leading to confusion. Pull Request resolved: https://github.com/pytorch/pytorch/pull/146475 Approved by: https://github.com/mikaylagawarecki --- torch/hub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torch/hub.py b/torch/hub.py index aa305823939..b3e99399691 100644 --- a/torch/hub.py +++ b/torch/hub.py @@ -262,7 +262,7 @@ def _get_cache_or_reload( try: url = _git_archive_link(repo_owner, repo_name, ref) - sys.stderr.write(f'Downloading: "{url}" to {cached_file}\n') + sys.stdout.write(f'Downloading: "{url}" to {cached_file}\n') download_url_to_file(url, cached_file, progress=False) except HTTPError as err: if err.code == 300: @@ -859,7 +859,7 @@ def load_state_dict_from_url( filename = file_name cached_file = os.path.join(model_dir, filename) if not os.path.exists(cached_file): - sys.stderr.write(f'Downloading: "{url}" to {cached_file}\n') + sys.stdout.write(f'Downloading: "{url}" to {cached_file}\n') hash_prefix = None if check_hash: r = HASH_REGEX.search(filename) # r is Optional[Match[str]]