From 0f6fe68c4f3234f15601f7ed3000f71cb57e19cb Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Sat, 7 Feb 2026 02:16:55 +0530 Subject: [PATCH] Fix KeyError when LOCAL_RANK env var is not set Use os.environ.get() with default value 0 instead of direct dict access to prevent KeyError when LOCAL_RANK is not set in the environment. This allows running on a single GPU without needing to set the environment variable. Fixes #379 --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 88acdb6a..ab7cb876 100644 --- a/config.py +++ b/config.py @@ -341,7 +341,7 @@ def _check_args(name): if PYTORCH_MAJOR_VERSION == 1: config.LOCAL_RANK = args.local_rank else: - config.LOCAL_RANK = int(os.environ['LOCAL_RANK']) + config.LOCAL_RANK = int(os.environ.get('LOCAL_RANK', 0)) # output folder config.OUTPUT = os.path.join(config.OUTPUT, config.MODEL.NAME, config.TAG)