Repository: Vchitect/VBench
Issue: Human Anomaly: KeyError: 'Adafactor is already registered in optimizer at torch.optim'
Root cause: External Dependency Breakage

Thank you for your excellent work. The above error occurred when I tried to run the inference file for Human Anomaly. I tried several different combinations of mmengine and transformers versions, but it still didn't work. Here is my conda environment:
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
absl-py                   2.2.1                    pypi_0    pypi
accelerate                1.2.1                    pypi_0    pypi
addict                    2.4.0                    pypi_0    pypi
aiohappyeyeballs          2.4.4                    pypi_0    pypi
aiohttp                   3.11.11                  pypi_0    pypi
aiosignal                 1.3.2                    pypi_0    pypi
albucore                  0.0.19                   pypi_0    pypi
albumentations            1.4.19                   pypi_0    pypi
altair                    5.5.0                    pypi_0    pypi
annotated-types           0.7.0                    pypi_0    pypi
antlr4-python3-runtime    4.9.3                    pypi_0    pypi
anyio                     4.8.0                    pypi_0    pypi
args                      0.1.0                    pypi_0    pypi
asttokens                 3.0.0                    pypi_0    pypi
astunparse                1.6.3                    pypi_0    pypi
async-timeout             5.0.1                    pypi_0    pypi
attrs                     24.3.0                   pypi_0    pypi
av                        14.0.1                   pypi_0    pypi
bcrypt                    4.3.0                    pypi_0    pypi
beautifulsoup4            4.12.3                   pypi_0    pypi
bitsandbytes              0.42.0                   pypi_0    pypi
blinker                   1.9.0                    pypi_0    pypi
blis                      1.2.0                    pypi_0    pypi
boto3                     1.26.90                  pypi_0    pypi
botocore                  1.29.165                 pypi_0    pypi
braceexpand               0.1.7                    pypi_0    pypi
bzip2                     1.0.8                h5eee18b_6  
ca-certificates           2025.2.25            h06a4308_0  
cachetools                5.5.2                    pypi_0    pypi
catalogue                 2.0.10                   pypi_0    pypi
certifi                   2024.12.14               pypi_0    pypi
cffi                      1.17.1                   pypi_0    pypi
charset-normalizer        3.4.1                    pypi_0    pypi
click                     8.1.8                    pypi_0    pypi
clint                     0.5.1                    pypi_0    pypi
clip                      1.0                      pypi_0    pypi
cloudpathlib              0.21.0                   pypi_0    pypi
cloudpickle               3.1.1                    pypi_0    pypi
colorama                  0.4.6                    pypi_0    pypi
coloredlogs               15.0.1                   pypi_0    pypi
confection                0.1.5                    pypi_0    pypi
configobj                 5.0.9                    pypi_0    pypi
contourpy                 1.3.1                    pypi_0    pypi
cryptography              44.0.2                   pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
cymem                     2.0.11                   pypi_0    pypi
cython                    3.0.12                   pypi_0    pypi
datasets                  3.2.0                    pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
decord                    0.6.0                    pypi_0    pypi
deep-sort-realtime        1.3.2                    pypi_0    pypi
deepspeed                 0.12.6                   pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
deprecated                1.2.18                   pypi_0    pypi
diffusers                 0.32.1                   pypi_0    pypi
dill                      0.3.8                    pypi_0    pypi
distro                    1.9.0                    pypi_0    pypi
docker-pycreds            0.4.0                    pypi_0    pypi
docopt                    0.6.2                    pypi_0    pypi
easydict                  1.13                     pypi_0    pypi
einops                    0.8.0                    pypi_0    pypi
einops-exts               0.0.4                    pypi_0    pypi
eval-type-backport        0.2.2                    pypi_0    pypi
exceptiongroup            1.2.2                    pypi_0    pypi
executing                 2.2.0                    pypi_0    pypi
fabric                    3.2.2                    pypi_0    pypi
fairscale                 0.4.13                   pypi_0    pypi
fastapi                   0.115.6                  pypi_0    pypi
filelock                  3.13.1                   pypi_0    pypi
filterpy                  1.4.5                    pypi_0    pypi
fire                      0.4.0                    pypi_0    pypi
flash-attn                2.7.2.post1              pypi_0    pypi
flatbuffers               25.2.10                  pypi_0    pypi
flowlib                   0.6.6.8                  pypi_0    pypi
fonttools                 4.55.3                   pypi_0    pypi
frozenlist                1.5.0                    pypi_0    pypi
fsspec                    2024.2.0                 pypi_0    pypi
ftfy                      6.3.1                    pypi_0    pypi
fvcore                    0.1.5.post20221221          pypi_0    pypi
gast                      0.6.0                    pypi_0    pypi
gdown                     5.2.0                    pypi_0    pypi
gevent                    24.11.1                  pypi_0    pypi
gitdb                     4.0.12                   pypi_0    pypi
gitpython                 3.1.44                   pypi_0    pypi
google-pasta              0.2.0                    pypi_0    pypi
greenlet                  3.1.1                    pypi_0    pypi
grpcio                    1.71.0                   pypi_0    pypi
h11                       0.14.0                   pypi_0    pypi
h5py                      3.12.1                   pypi_0    pypi
hjson                     3.1.0                    pypi_0    pypi
hpsv2                     1.2.0                    pypi_0    pypi
httpcore                  1.0.7                    pypi_0    pypi
httpx                     0.28.1                   pypi_0    pypi
huggingface-hub           0.27.1                   pypi_0    pypi
humanfriendly             10.0                     pypi_0    pypi
idna                      3.10                     pypi_0    pypi
iglovikov-helper-functions 0.0.53                   pypi_0    pypi
imagecorruptions          1.1.2                    pypi_0    pypi
imageio                   2.37.0                   pypi_0    pypi
imageio-ffmpeg            0.6.0                    pypi_0    pypi
importlib-metadata        8.5.0                    pypi_0    pypi
iniconfig                 2.0.0                    pypi_0    pypi
invoke                    2.2.0                    pypi_0    pypi
iopath                    0.1.10                   pypi_0    pypi
ipdb                      0.13.13                  pypi_0    pypi
ipython                   8.32.0                   pypi_0    pypi
jax                       0.5.3                    pypi_0    pypi
jaxlib                    0.5.3                    pypi_0    pypi
jedi                      0.19.2                   pypi_0    pypi
jinja2                    3.1.3                    pypi_0    pypi
jiter                     0.8.2                    pypi_0    pypi
jmespath                  1.0.1                    pypi_0    pypi
joblib                    1.4.2                    pypi_0    pypi
jpeg4py                   0.1.4                    pypi_0    pypi
jsonschema                4.23.0                   pypi_0    pypi
jsonschema-specifications 2024.10.1                pypi_0    pypi
keras                     3.9.1                    pypi_0    pypi
kiwisolver                1.4.8                    pypi_0    pypi
kornia                    0.5.6                    pypi_0    pypi
kornia-rs                 0.1.8                    pypi_0    pypi
langcodes                 3.5.0                    pypi_0    pypi
language-data             1.3.0                    pypi_0    pypi
lazy-loader               0.4                      pypi_0    pypi
ld_impl_linux-64          2.40                 h12ee557_0  
libclang                  18.1.1                   pypi_0    pypi
libffi                    3.4.4                h6a678d5_1  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
libuuid                   1.41.5               h5eee18b_0  
llava                     1.7.0.dev0               pypi_0    pypi
logger                    1.4                      pypi_0    pypi
lvis                      0.5.3                    pypi_0    pypi
marisa-trie               1.2.1                    pypi_0    pypi
markdown                  3.7                      pypi_0    pypi
markdown-it-py            3.0.0                    pypi_0    pypi
markupsafe                2.1.5                    pypi_0    pypi
matplotlib                3.10.0                   pypi_0    pypi
matplotlib-inline         0.1.7                    pypi_0    pypi
mdurl                     0.1.2                    pypi_0    pypi
mediapipe                 0.10.11                  pypi_0    pypi
ml-dtypes                 0.5.1                    pypi_0    pypi
mmcv                      2.2.0                    pypi_0    pypi
mmcv-lite                 2.2.0                    pypi_0    pypi
mmdet                     3.0.0                    pypi_0    pypi
mmengine                  0.10.5                   pypi_0    pypi
mmyolo                    0.6.0                    pypi_0    pypi
model-index               0.1.11                   pypi_0    pypi
mpmath                    1.3.0                    pypi_0    pypi
msgpack                   1.1.0                    pypi_0    pypi
multidict                 6.1.0                    pypi_0    pypi
multiprocess              0.70.16                  pypi_0    pypi
murmurhash                1.0.12                   pypi_0    pypi
namex                     0.0.8                    pypi_0    pypi
narwhals                  1.33.0                   pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
networkx                  3.2.1                    pypi_0    pypi
ninja                     1.11.1.4                 pypi_0    pypi
nltk                      3.9.1                    pypi_0    pypi
numpy                     1.26.3                   pypi_0    pypi
nvidia-cublas-cu11        11.11.3.6                pypi_0    pypi
nvidia-cuda-cupti-cu11    11.8.87                  pypi_0    pypi
nvidia-cuda-nvrtc-cu11    11.8.89                  pypi_0    pypi
nvidia-cuda-runtime-cu11  11.8.89                  pypi_0    pypi
nvidia-cudnn-cu11         9.1.0.70                 pypi_0    pypi
nvidia-cufft-cu11         10.9.0.58                pypi_0    pypi
nvidia-curand-cu11        10.3.0.86                pypi_0    pypi
nvidia-cusolver-cu11      11.4.1.48                pypi_0    pypi
nvidia-cusparse-cu11      11.7.5.86                pypi_0    pypi
nvidia-ml-py              12.570.86                pypi_0    pypi
nvidia-nccl-cu11          2.21.5                   pypi_0    pypi
nvidia-nvtx-cu11          11.8.86                  pypi_0    pypi
omegaconf                 2.3.0                    pypi_0    pypi
onnx                      1.17.0                   pypi_0    pypi
onnxruntime               1.16.3                   pypi_0    pypi
open-clip-torch           2.30.0                   pypi_0    pypi
openai                    1.59.5                   pypi_0    pypi
opencv-contrib-python     4.11.0.86                pypi_0    pypi
opencv-python             4.10.0.84                pypi_0    pypi
opencv-python-headless    4.10.0.84                pypi_0    pypi
opendatalab               0.0.10                   pypi_0    pypi
openmim                   0.3.9                    pypi_0    pypi
openssl                   3.0.16               h5eee18b_0  
openxlab                  0.0.11                   pypi_0    pypi
opt-einsum                3.4.0                    pypi_0    pypi
optree                    0.14.1                   pypi_0    pypi
ordered-set               4.1.0                    pypi_0    pypi
outcome                   1.3.0.post0              pypi_0    pypi
packaging                 24.2                     pypi_0    pypi
pandas                    2.2.3                    pypi_0    pypi
paramiko                  3.5.1                    pypi_0    pypi
parso                     0.8.4                    pypi_0    pypi
peft                      0.14.0                   pypi_0    pypi
pexpect                   4.9.0                    pypi_0    pypi
pillow                    10.2.0                   pypi_0    pypi
pip                       25.0            py310h06a4308_0  
platformdirs              4.3.6                    pypi_0    pypi
pluggy                    1.5.0                    pypi_0    pypi
portalocker               3.1.1                    pypi_0    pypi
preshed                   3.0.9                    pypi_0    pypi
prettytable               3.14.0                   pypi_0    pypi
prompt-toolkit            3.0.50                   pypi_0    pypi
propcache                 0.2.1                    pypi_0    pypi
protobuf                  3.20.3                   pypi_0    pypi
psutil                    5.9.0           py310h5eee18b_1  
ptyprocess                0.7.0                    pypi_0    pypi
pure-eval                 0.2.3                    pypi_0    pypi
py-cpuinfo                9.0.0                    pypi_0    pypi
pyarrow                   18.1.0                   pypi_0    pypi
pybboxes                  0.1.6                    pypi_0    pypi
pycocoevalcap             1.2                      pypi_0    pypi
pycocotools               2.0.8                    pypi_0    pypi
pycparser                 2.22                     pypi_0    pypi
pycryptodome              3.22.0                   pypi_0    pypi
pydantic                  2.10.4                   pypi_0    pypi
pydantic-core             2.27.2                   pypi_0    pypi
pydeck                    0.9.1                    pypi_0    pypi
pyecharts                 2.0.8                    pypi_0    pypi
pygments                  2.19.1                   pypi_0    pypi
pynacl                    1.5.0                    pypi_0    pypi
pynvml                    12.0.0                   pypi_0    pypi
pyparsing                 3.2.1                    pypi_0    pypi
pysocks                   1.7.1                    pypi_0    pypi
pytest                    7.2.0                    pypi_0    pypi
pytest-split              0.8.0                    pypi_0    pypi
python                    3.10.16              he870216_1  
python-dateutil           2.9.0.post0              pypi_0    pypi
pytz                      2024.2                   pypi_0    pypi
pyyaml                    6.0.2                    pypi_0    pypi
qudida                    0.0.4                    pypi_0    pypi
readline                  8.2                  h5eee18b_0  
referencing               0.36.2                   pypi_0    pypi
regex                     2024.11.6                pypi_0    pypi
requests                  2.32.3                   pypi_0    pypi
retina-face               0.0.17                   pypi_0    pypi
retinaface-pytorch        0.0.8                    pypi_0    pypi
rich                      13.9.4                   pypi_0    pypi
rpds-py                   0.24.0                   pypi_0    pypi
s3transfer                0.6.2                    pypi_0    pypi
safetensors               0.5.2                    pypi_0    pypi
sahi                      0.11.22                  pypi_0    pypi
scenedetect               0.6.5.2                  pypi_0    pypi
scikit-image              0.25.0                   pypi_0    pypi
scikit-learn              1.6.0                    pypi_0    pypi
scipy                     1.15.0                   pypi_0    pypi
seaborn                   0.13.2                   pypi_0    pypi
selenium                  4.29.0                   pypi_0    pypi
sentencepiece             0.2.0                    pypi_0    pypi
sentry-sdk                2.19.2                   pypi_0    pypi
setproctitle              1.3.4                    pypi_0    pypi
setuptools                75.8.0          py310h06a4308_0  
sh                        2.2.2                    pypi_0    pypi
shapely                   2.0.7                    pypi_0    pypi
shellingham               1.5.4                    pypi_0    pypi
simplejson                3.20.1                   pypi_0    pypi
six                       1.17.0                   pypi_0    pypi
smart-open                7.1.0                    pypi_0    pypi
smmap                     5.0.2                    pypi_0    pypi
snapshot-selenium         0.0.2                    pypi_0    pypi
sniffio                   1.3.1                    pypi_0    pypi
sortedcontainers          2.4.0                    pypi_0    pypi
sounddevice               0.5.1                    pypi_0    pypi
soupsieve                 2.6                      pypi_0    pypi
spacy                     3.8.4                    pypi_0    pypi
spacy-legacy              3.0.12                   pypi_0    pypi
spacy-loggers             1.0.5                    pypi_0    pypi
sqlite                    3.45.3               h5eee18b_0  
srsly                     2.5.1                    pypi_0    pypi
stack-data                0.6.3                    pypi_0    pypi
starlette                 0.41.3                   pypi_0    pypi
streamlit                 1.44.1                   pypi_0    pypi
stringzilla               3.12.3                   pypi_0    pypi
supervision               0.19.0                   pypi_0    pypi
sympy                     1.13.1                   pypi_0    pypi
tabulate                  0.9.0                    pypi_0    pypi
tenacity                  9.0.0                    pypi_0    pypi
tensorboard               2.19.0                   pypi_0    pypi
tensorboard-data-server   0.7.2                    pypi_0    pypi
tensorflow                2.19.0                   pypi_0    pypi
tensorflow-io-gcs-filesystem 0.37.1                   pypi_0    pypi
termcolor                 2.5.0                    pypi_0    pypi
terminaltables            3.1.10                   pypi_0    pypi
thinc                     8.3.4                    pypi_0    pypi
thop                      0.1.1-2209072238          pypi_0    pypi
threadpoolctl             3.5.0                    pypi_0    pypi
tifffile                  2025.1.10                pypi_0    pypi
tiktoken                  0.8.0                    pypi_0    pypi
timesformer-pytorch       0.4.1                    pypi_0    pypi
timm                      0.4.12                   pypi_0    pypi
tk                        8.6.14               h39e8969_0  
tokenizers                0.21.1                   pypi_0    pypi
toml                      0.10.2                   pypi_0    pypi
tomli                     2.2.1                    pypi_0    pypi
torch                     2.5.1+cu118              pypi_0    pypi
torchaudio                2.5.1+cu118              pypi_0    pypi
torchvision               0.20.1+cu118             pypi_0    pypi
tornado                   6.4.2                    pypi_0    pypi
tqdm                      4.67.1                   pypi_0    pypi
traitlets                 5.14.3                   pypi_0    pypi
transformers              4.47.1                   pypi_0    pypi
trio                      0.29.0                   pypi_0    pypi
trio-websocket            0.12.2                   pypi_0    pypi
triton                    3.1.0                    pypi_0    pypi
typer                     0.15.2                   pypi_0    pypi
typing-extensions         4.12.2                   pypi_0    pypi
tzdata                    2024.2                   pypi_0    pypi
ultralytics               8.3.68                   pypi_0    pypi
ultralytics-thop          2.0.14                   pypi_0    pypi
unicorn                   2.1.1                    pypi_0    pypi
urllib3                   1.26.15                  pypi_0    pypi
wandb                     0.19.2                   pypi_0    pypi
wasabi                    1.1.3                    pypi_0    pypi
watchdog                  6.0.0                    pypi_0    pypi
wcwidth                   0.2.13                   pypi_0    pypi
weasel                    0.4.1                    pypi_0    pypi
webdataset                0.2.100                  pypi_0    pypi
websocket                 0.2.1                    pypi_0    pypi
websocket-client          1.8.0                    pypi_0    pypi
werkzeug                  3.1.3                    pypi_0    pypi
wheel                     0.45.1          py310h06a4308_0  
wordcloud                 1.9.4                    pypi_0    pypi
wrapt                     1.17.2                   pypi_0    pypi
wsproto                   1.2.0                    pypi_0    pypi
xxhash                    3.5.0                    pypi_0    pypi
xz                        5.6.4                h5eee18b_1  
yacs                      0.1.8                    pypi_0    pypi
yapf                      0.43.0                   pypi_0    pypi
yarl                      1.18.3                   pypi_0    pypi
yolo-world                0.1.0                    pypi_0    pypi
yolov5                    7.0.10                   pypi_0    pypi
zipp                      3.21.0                   pypi_0    pypi
zlib                      1.2.13               h5eee18b_1  
zope-event                5.0                      pypi_0    pypi
zope-interface            7.2                      pypi_0    pypi

Hello, could you please check the first 9 lines of `inference.py` and confirm if they match the following?

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import json
import cv2
import mmcv
import torch
import logging
import argparse
import hack_registry

if not, it is not the latest code.

> Hello, could you please check the first 9 lines of `inference.py` and confirm if they match the following?
> 
> import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import json import cv2 import mmcv import torch import logging import argparse import hack_registry
> 
> if not, it is not the latest code.

I used the latest code.

This issue is caused by using a version of PyTorch higher than 2.4. There are two solutions available online: one is to downgrade PyTorch to version 2.4.0, and the other is to import `hack_registry`. I resolved the problem using the second method. If that doesn't work for you, the only option would be to downgrade the PyTorch version. Here is the link of solution https://github.com/open-mmlab/mmdetection/issues/12008#issuecomment-2449327570

> This issue is caused by using a version of PyTorch higher than 2.4. There are two solutions available online: one is to downgrade PyTorch to version 2.4.0, and the other is to import `hack_registry`. I resolved the problem using the second method. If that doesn't work for you, the only option would be to downgrade the PyTorch version. Here is the link of solution [open-mmlab/mmdetection#12008 (comment)](https://github.com/open-mmlab/mmdetection/issues/12008#issuecomment-2449327570)

I noticed the solution you mentioned, and unfortunately, it doesn't work. In addition, I also tried to replace pytorch versions, including 2.4, and got The following error: RuntimeError: The NVIDIA driver on your system is too old (found version 11080). 
But I can't replace the cuda version of the public GPU, is there another solution?

What is the command you used to downgrade PyTorch?

> What is the command you used to downgrade PyTorch?

pip uninstall torch torchvision torchaudio
pip install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0

I am reinstalling whole the environment with torch==2.4.0, it looks like the installation went smoothly. I suggest you reinstall the environment from scratch, but change torch to the following command: pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu118

> I am reinstalling whole the environment with torch==2.4.0, it looks like the installation went smoothly. I suggest you reinstall the environment from scratch, but change torch to the following command: pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu118


conda create -n vbench2 python=3.10 -y
conda activate vbench2
conda install psutil
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu118 
python -m pip install ninja
python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.7.2.post1
pip install -r requirement.txt
pip install mmcv==2.2.0 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.4/index.html --no-cache-dir
pip install retinaface_pytorch==0.0.8 --no-deps


I followed the above command to reinstall the runtime environment, but the following error still occurs:
RuntimeError: The NVIDIA driver on your system is too old (found version 11080). 

Check out whether you correctly set the cuda to 11.8

> Check out whether you correctly set the cuda to 11.8

NVCC --version：
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

Well, it seems there might be some issues with your environment. We recommend switching back to torch 2.5.1 and performing a complete reinstallation of the environment to ensure that gcc and cuda are correctly configured. We have double-checked this environment setup on three different machines, and it worked without any issues.

> Well, it seems there might be some issues with your environment. We recommend switching back to torch 2.5.1 and performing a complete reinstallation of the environment to ensure that gcc and cuda are correctly configured. We have double-checked this environment setup on three different machines, and it worked without any issues.

Although I don't know exactly where the fault is, I have replaced the machine and it can work now. Thank you for your patience, I close this issue.