zhiyuanyou / UniAD

[NeurIPS 2022 Spotlight] A Unified Model for Multi-class Anomaly Detection
Apache License 2.0
250 stars 28 forks source link

Error:Exception has occurred: KeyError 'RANK' #10

Closed Tristesse-stk closed 2 years ago

Tristesse-stk commented 2 years ago

When I run the train_val.py in tools the error occurs in rank = int(os.environ["RANK"]) in dist_helper.py The error is reported as follows. Exception has occurred: KeyError 'RANK'

During handling of the above exception, another exception occurred:

File "D:\Python\UniAD\utils\dist_helper.py", line 31, in setup_distributed rank = int(os.environ["RANK"]) File "D:\Python\UniAD\tools\train_val.py", line 61, in main rank, world_size = utils.dist_helper.setup_distributed(port=config.port) File "D:\Python\UniAD\tools\train_val.py", line 343, in main()

How to solve this problem?

zhiyuanyou commented 2 years ago

Well, I wonder how you run train_val.py? (the command you input to the terminal)

---Original--- From: @.> Date: Wed, Nov 2, 2022 21:01 PM To: @.>; Cc: @.***>; Subject: [zhiyuanyou/UniAD] Error:Exception has occurred: KeyError 'RANK'(Issue #10)

When I run the train_val.py in tools the error occurs in rank = int(os.environ["RANK"]) in dist_helper.py The error is reported as follows. Exception has occurred: KeyError 'RANK'

During handling of the above exception, another exception occurred:

File "D:\Python\UniAD\utils\dist_helper.py", line 31, in setup_distributed rank = int(os.environ["RANK"]) File "D:\Python\UniAD\tools\train_val.py", line 61, in main rank, world_size = utils.dist_helper.setup_distributed(port=config.port) File "D:\Python\UniAD\tools\train_val.py", line 343, in main()

How to solve this problem?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

zhiyuanyou commented 2 years ago

I noticed that you used Windows rather than Ubuntu, which is our code based on. I suggest you to try

CUDA_VISIBLE_DEVICES=$2
python -m torch.distributed.launch --nproc_per_node=$1 ..\..\tools\train_val.py

Then you could use sh train_torch.sh #NUM_GPUS #GPU_IDS to train, e.g., sh train_torch.sh 1 0 means using GPU 0 to train.

Ehteshamciitwah commented 1 year ago

Hello, Thank you for your work.

i am implementing your GitHub repository on my Window system. I will use Pycharm IDE for debugging and understanding. While implementing I am getting the error "Error:Exception has occurred: KeyError 'RANK'". Instead of using terminal i am using Pycharm debug and run.

I am looking for your response. Thank you

zhiyuanyou commented 1 year ago

Hello, Thank you for your work.

i am implementing your GitHub repository on my Window system. I will use Pycharm IDE for debugging and understanding. While implementing I am getting the error "Error:Exception has occurred: KeyError 'RANK'". Instead of using terminal i am using Pycharm debug and run.

I am looking for your response. Thank you

Hi~

This error is caused because Windows does not have the Environment Variable "RANK". Our codes have been verified on Ubuntu, so I suggest you to switch to Ubuntu. Otherwise, it needs too many works to solve these problems.