marrlab / DomainLab

modular domain generalization: https://pypi.org/project/domainlab/
https://marrlab.github.io/DomainLab/
MIT License
40 stars 2 forks source link

backpack extend not defined #805

Open SinaWend opened 2 months ago

SinaWend commented 2 months ago

When trying to execute an experiment with the command domainlab -c ./examples/conf/vlcs_dinov2.yaml I get the error: Traceback (most recent call last): File "/opt/anaconda3/envs/domainlab_py39/bin/domainlab", line 5, in <module> from domainlab.cli import domainlab_cli File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/cli.py", line 7, in <module> from domainlab.exp.exp_main import Exp File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/exp/exp_main.py", line 8, in <module> from domainlab.algos.zoo_algos import AlgoBuilderChainNodeGetter File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/algos/zoo_algos.py", line 5, in <module> from domainlab.algos.builder_dann import NodeAlgoBuilderDANN File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/algos/builder_dann.py", line 14, in <module> from domainlab.models.model_dann import mk_dann File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/models/model_dann.py", line 9, in <module> from domainlab.models.a_model_classif import AModelClassif File "/opt/anaconda3/envs/domainlab_py39/lib/python3.9/site-packages/domainlab/models/a_model_classif.py", line 26, in <module> loss_cross_entropy_extended = extend(nn.CrossEntropyLoss(reduction="none")) NameError: name 'extend' is not defined. I installed the backpack and backpack-for-pytorch packages, but the error still occurs.

smilesun commented 2 months ago

@SinaWend , is your version domainlab 0.6.2?

smilesun commented 2 months ago

@MatteoWohlrapp , could you check if domainlab -c ./examples/conf/vlcs_diva_mldg_dial.yaml

works?

In general, we need to wrap around that line of backpack-for-pytorch import so that as long as we do not use it, it won't pop up an error.

SinaWend commented 2 months ago

It gives the same error.

MatteoWohlrapp commented 2 months ago

I created a new conda environment with Python 3.10 and installed the newest PyPi domainlab package 0.6.2. Running domainlab -c ./examples/conf/vlcs_diva_mldg_dial.yam for me works. @SinaWend can you maybe share the versions you have, and the content of the .yaml file so that I can reproduce the error?

MatteoWohlrapp commented 1 month ago

@smilesun I now get the same error. Maybe it is connected to which compute node you are assigned to. I got a new one which also needed another pytorch version to connect to cuda.

SinaWend commented 1 month ago

Sorry for the late reply, these are the packages I have installed: appdirs 1.4.4 attrs 23.2.0 backpack-for-pytorch 1.6.0 beautifulsoup4 4.12.3 Brotli 1.0.9 certifi 2023.11.17 cffi 1.16.0 charset-normalizer 3.3.2 ConfigArgParse 1.7 connection-pool 0.0.3 contourpy 1.2.0 cycler 0.12.1 datrie 0.8.2 debugpy 1.8.1 docutils 0.21.1 domainlab 0.6.2 dpath 2.1.6 einops 0.7.0 fastjsonschema 2.19.1 filelock 3.13.1 fonttools 4.47.2 fsspec 2024.3.1 future 1.0.0 gdown 4.7.3 gitdb 4.0.11 GitPython 3.1.43 gmpy2 2.1.2 huggingface-hub 0.22.2 humanfriendly 10.0 idna 3.6 imbalanced-learn 0.12.2 importlib_resources 6.4.0 Jinja2 3.1.3 joblib 1.3.2 jsonschema 4.21.1 jsonschema-specifications 2023.12.1 jupyter_core 5.7.2 kiwisolver 1.4.5 markdown-it-py 3.0.0 MarkupSafe 2.1.3 matplotlib 3.8.2 mdurl 0.1.2 mkl-fft 1.3.8 mkl-random 1.2.4 mkl-service 2.4.0 mpmath 1.3.0 nbformat 5.10.4 networkx 3.1 numpy 1.26.3 opencv-python 4.9.0.80 packaging 23.2 pandas 1.5.3 Pillow 9.5.0 pip 23.3.1 plac 1.4.3 platformdirs 4.2.0 psutil 5.9.8 PuLP 2.7.0 pycparser 2.22 Pygments 2.17.2 pyparsing 3.1.1 PySocks 1.7.1 python-dateutil 2.8.2 pytz 2023.4 PyYAML 6.0.1 referencing 0.34.0 requests 2.31.0 reretry 0.11.8 rich 13.7.0 rpds-py 0.18.0 safetensors 0.4.3 scikit-learn 1.4.0 scipy 1.12.0 seaborn 0.12.2 setuptools 68.2.2 shapely 2.0.4 six 1.16.0 slideio 2.4.1 smart-open 7.0.4 smmap 5.0.1 snakemake 7.32.4 soupsieve 2.5 stopit 1.1.2 sympy 1.12 tabulate 0.9.0 threadpoolctl 3.2.0 throttler 1.2.2 timm 0.9.16 toposort 1.10 torch 1.12.1 torchaudio 0.12.1 torchmetrics 0.10.3 torchvision 0.13.1 tqdm 4.66.1 traitlets 5.14.2 triton 2.3.0 typing_extensions 4.9.0 unfoldNd 0.2.1 urllib3 2.1.0 wheel 0.41.2 wrapt 1.16.0 yte 1.5.4

MatteoWohlrapp commented 1 month ago

If you are on the node gpusrv34, you could try and set the following versions torch-2.3.0 torchvision-0.18.0 triton-2.3.0.