Closed fredguth closed 1 year ago
Hi Fred,
could you let me know how you installed BackPACK? Or post the result of pip show backpack-for-pytorch
? That would be helpful to figure out the issue.
Best, Felix
I installed via pip using the installation instructions in the site. Using python 3.9 an torch 1.12
Name: backpack-for-pytorch
Version: 1.5.1
Summary: BackPACK: Packing more into backprop
Home-page: https://github.com/f-dangel/backpack
Author: Felix Dangel, Frederik Kunstner
Author-email:
License: MIT
Location: /home/fredguth/.miniconda3/envs/py39/lib/python3.9/site-packages
Requires: einops, torch, torchvision
Required-by:```
Hi Fred, thanks for the report.
I tried to reproduce your problem with the following:
# create an environment with python 3.9
conda create --name backpack-issue-294 python=3.9
# activate it
conda activate backpack-issue-294
# install dependencies
pip install backpack-for-pytorch==1.5.1 torch==1.12.1
# try importing
python -c "from backpack import backpack, extend"
but did not encounter problems.
Not sure where exactly your problem lies. Do you get the same error using the above instructions?
With the backpack-issue-294 environment, it works. There is something in my conda environment that is breaking backpack. I am attaching both environment lists
name: backpack-issue-294
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2022.10.11=h06a4308_0
- certifi=2022.9.24=py39h06a4308_0
- ld_impl_linux-64=2.38=h1181459_1
- libffi=3.4.2=h6a678d5_6
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.3=h5eee18b_3
- openssl=1.1.1s=h7f8727e_0
- pip=22.3.1=py39h06a4308_0
- python=3.9.15=h7a1cb2a_2
- readline=8.2=h5eee18b_0
- setuptools=65.5.0=py39h06a4308_0
- sqlite=3.40.0=h5082296_0
- tk=8.6.12=h1ccaba5_0
- tzdata=2022g=h04d1e81_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.2.8=h5eee18b_0
- zlib=1.2.13=h5eee18b_0
- pip:
- backpack-for-pytorch==1.5.1
- charset-normalizer==2.1.1
- einops==0.6.0
- idna==3.4
- numpy==1.23.5
- pillow==9.3.0
- requests==2.28.1
- torch==1.12.1
- torchvision==0.13.1
- typing-extensions==4.4.0
- urllib3==1.26.13
prefix: /home/fredguth/.miniconda3/envs/backpack-issue-294
This other one that I create, also works:
name: backpack-2
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2022.10.11=h06a4308_0
- certifi=2022.9.24=py39h06a4308_0
- ld_impl_linux-64=2.38=h1181459_1
- libffi=3.4.2=h6a678d5_6
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.3=h5eee18b_3
- openssl=1.1.1s=h7f8727e_0
- pip=22.3.1=py39h06a4308_0
- python=3.9.15=h7a1cb2a_2
- readline=8.2=h5eee18b_0
- setuptools=65.5.0=py39h06a4308_0
- sqlite=3.40.0=h5082296_0
- tk=8.6.12=h1ccaba5_0
- tzdata=2022g=h04d1e81_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.2.8=h5eee18b_0
- zlib=1.2.13=h5eee18b_0
- pip:
- absl-py==1.3.0
- aiohttp==3.8.3
- aiosignal==1.3.1
- anyio==3.6.2
- argon2-cffi==21.3.0
- argon2-cffi-bindings==21.2.0
- arrow==1.2.3
- asttokens==2.2.1
- astunparse==1.6.3
- async-timeout==4.0.2
- attrs==22.1.0
- babel==2.11.0
- backcall==0.2.0
- backpack-for-pytorch==1.5.1
- beautifulsoup4==4.11.1
- bleach==5.0.1
- cachetools==5.2.0
- cffi==1.15.1
- charset-normalizer==2.1.1
- comm==0.1.2
- contourpy==1.0.6
- cycler==0.11.0
- datasets==2.7.1
- debugpy==1.6.4
- decorator==5.1.1
- defusedxml==0.7.1
- diffusers==0.10.2
- dill==0.3.6
- einops==0.6.0
- entrypoints==0.4
- execnb==0.1.4
- executing==1.2.0
- fastcore==1.5.27
- fastjsonschema==2.16.2
- fastprogress==1.0.3
- filelock==3.8.2
- fonttools==4.38.0
- fqdn==1.5.1
- frozenlist==1.3.3
- fsspec==2022.11.0
- ghapi==1.0.3
- google-auth==2.15.0
- google-auth-oauthlib==0.4.6
- grpcio==1.51.1
- huggingface-hub==0.11.1
- idna==3.4
- importlib-metadata==5.1.0
- ipykernel==6.19.2
- ipython==8.7.0
- ipython-genutils==0.2.0
- isoduration==20.11.0
- jedi==0.18.2
- jinja2==3.1.2
- json5==0.9.10
- jsonpointer==2.3
- jsonschema==4.17.3
- jupyter-client==7.4.8
- jupyter-core==5.1.0
- jupyter-events==0.5.0
- jupyter-server==2.0.1
- jupyter-server-terminals==0.4.2
- jupyterlab==3.5.1
- jupyterlab-pygments==0.2.2
- jupyterlab-server==2.16.5
- kiwisolver==1.4.4
- markdown==3.4.1
- markupsafe==2.1.1
- matplotlib==3.6.2
- matplotlib-inline==0.1.6
- mistune==2.0.4
- multidict==6.0.3
- multiprocess==0.70.14
- mypy-extensions==0.4.3
- nbclassic==0.4.8
- nbclient==0.7.2
- nbconvert==7.2.6
- nbdev==2.3.9
- nbformat==5.7.0
- nest-asyncio==1.5.6
- notebook==6.5.2
- notebook-shim==0.2.2
- numpy==1.23.5
- oauthlib==3.2.2
- packaging==22.0
- pandas==1.5.2
- pandocfilters==1.5.0
- parso==0.8.3
- pexpect==4.8.0
- pickleshare==0.7.5
- pillow==9.3.0
- platformdirs==2.6.0
- prometheus-client==0.15.0
- prompt-toolkit==3.0.36
- protobuf==3.20.3
- psutil==5.9.4
- ptyprocess==0.7.0
- pure-eval==0.2.2
- pyarrow==10.0.1
- pyasn1==0.4.8
- pyasn1-modules==0.2.8
- pycparser==2.21
- pygments==2.13.0
- pyparsing==3.0.9
- pyre-extensions==0.0.30
- pyrsistent==0.19.2
- python-dateutil==2.8.2
- python-json-logger==2.0.4
- pytz==2022.6
- pyyaml==6.0
- pyzmq==24.0.1
- regex==2022.10.31
- requests==2.28.1
- requests-oauthlib==1.3.1
- responses==0.18.0
- rfc3339-validator==0.1.4
- rfc3986-validator==0.1.1
- rsa==4.9
- send2trash==1.8.0
- six==1.16.0
- sniffio==1.3.0
- soupsieve==2.3.2.post1
- stack-data==0.6.2
- tensorboard==2.11.0
- tensorboard-data-server==0.6.1
- tensorboard-plugin-wit==1.8.1
- terminado==0.17.1
- tinycss2==1.2.1
- tomli==2.0.1
- torch==1.12.1
- torcheval==0.0.5
- torchtnt==0.0.4
- torchvision==0.13.1
- tornado==6.2
- tqdm==4.64.1
- traitlets==5.7.1
- typing-extensions==4.4.0
- typing-inspect==0.8.0
- uri-template==1.2.0
- urllib3==1.26.13
- watchdog==2.2.0
- wcwidth==0.2.5
- webcolors==1.12
- webencodings==0.5.1
- websocket-client==1.4.2
- werkzeug==2.2.2
- xxhash==3.1.0
- yarl==1.8.2
- zipp==3.11.0
prefix: /home/fredguth/.miniconda3/envs/backpack-2
This one does not work:
name: py39
channels:
- pytorch-nightly
- nvidia
- fastchan
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- blas=1.0=mkl
- brotli-bin=1.0.9=h166bdaf_7
- brotlipy=0.7.0=py39h27cfd23_1003
- bzip2=1.0.8=h7b6447c_0
- ca-certificates=2022.10.11=h06a4308_0
- catalogue=2.0.8=py39hf3d152e_0
- certifi=2022.9.24=pyhd8ed1ab_0
- cffi=1.15.1=py39h74dc2b5_0
- charset-normalizer=2.0.4=pyhd3eb1b0_0
- click=8.1.3=py39hf3d152e_0
- colorama=0.4.6=pyhd8ed1ab_0
- cryptography=38.0.1=py39h9ce1e76_0
- cuda=11.7.1=0
- cuda-cccl=11.7.91=0
- cuda-command-line-tools=11.7.1=0
- cuda-compiler=11.7.1=0
- cuda-cudart=11.7.99=0
- cuda-cudart-dev=11.7.99=0
- cuda-cuobjdump=11.7.91=0
- cuda-cupti=11.7.101=0
- cuda-cuxxfilt=11.7.91=0
- cuda-demo-suite=11.8.86=0
- cuda-documentation=11.8.86=0
- cuda-driver-dev=11.7.99=0
- cuda-gdb=11.8.86=0
- cuda-libraries=11.7.1=0
- cuda-libraries-dev=11.7.1=0
- cuda-memcheck=11.8.86=0
- cuda-nsight=11.8.86=0
- cuda-nsight-compute=11.8.0=0
- cuda-nvcc=11.7.99=0
- cuda-nvdisasm=11.8.86=0
- cuda-nvml-dev=11.7.91=0
- cuda-nvprof=11.8.87=0
- cuda-nvprune=11.7.91=0
- cuda-nvrtc=11.7.99=0
- cuda-nvrtc-dev=11.7.99=0
- cuda-nvtx=11.7.91=0
- cuda-nvvp=11.8.87=0
- cuda-runtime=11.7.1=0
- cuda-sanitizer-api=11.8.86=0
- cuda-toolkit=11.7.1=0
- cuda-tools=11.7.1=0
- cuda-visual-tools=11.7.1=0
- cycler=0.11.0=pyhd8ed1ab_0
- cython-blis=0.7.7=py39hd257fcd_1
- dataclasses=0.8=pyhc8e2a94_3
- dbus=1.13.18=hb2f20db_0
- expat=2.4.8=h27087fc_0
- fastai=2.7.10=py_0
- fastcore=1.5.27=py_0
- fastdownload=0.0.7=py_0
- fastprogress=1.0.3=py_0
- ffmpeg=4.2.2=h20bf706_0
- fftw=3.3.10=nompi_h77c792f_102
- fontconfig=2.14.0=h8e229c2_0
- freetype=2.12.1=h4a9f257_0
- gds-tools=1.4.0.31=0
- giflib=5.2.1=h7b6447c_0
- glib=2.69.1=h4ff587b_1
- gmp=6.2.1=h295c915_3
- gnutls=3.6.15=he1e5248_0
- gst-plugins-base=1.14.0=h8213a91_2
- gstreamer=1.14.0=h28cd5cc_2
- icu=58.2=he6710b0_3
- idna=3.4=py39h06a4308_0
- intel-openmp=2021.4.0=h06a4308_3561
- jinja2=3.1.2=pyhd8ed1ab_0
- joblib=1.2.0=pyhd8ed1ab_0
- jpeg=9e=h7f8727e_0
- keyutils=1.6.1=h166bdaf_0
- krb5=1.19.3=h3790be6_0
- lame=3.100=h7b6447c_0
- langcodes=3.3.0=pyhd8ed1ab_0
- lcms2=2.12=h3be6417_0
- ld_impl_linux-64=2.38=h1181459_1
- lerc=3.0=h295c915_0
- libbrotlicommon=1.0.9=h166bdaf_7
- libbrotlidec=1.0.9=h166bdaf_7
- libbrotlienc=1.0.9=h166bdaf_7
- libclang=10.0.1=default_hb85057a_2
- libcublas=11.11.3.6=0
- libcublas-dev=11.11.3.6=0
- libcufft=10.9.0.58=0
- libcufft-dev=10.9.0.58=0
- libcufile=1.4.0.31=0
- libcufile-dev=1.4.0.31=0
- libcurand=10.3.0.86=0
- libcurand-dev=10.3.0.86=0
- libcusolver=11.4.1.48=0
- libcusolver-dev=11.4.1.48=0
- libcusparse=11.7.5.86=0
- libcusparse-dev=11.7.5.86=0
- libdeflate=1.8=h7f8727e_5
- libedit=3.1.20210910=h7f8727e_0
- libevent=2.1.12=h8f2d780_0
- libffi=3.3=he6710b0_2
- libgcc-ng=11.2.0=h1234567_1
- libgfortran-ng=12.2.0=h69a702a_18
- libgfortran5=12.2.0=h337968e_18
- libgomp=11.2.0=h1234567_1
- libidn2=2.3.2=h7f8727e_0
- libllvm10=10.0.1=hbcb73fb_5
- libnpp=11.8.0.86=0
- libnpp-dev=11.8.0.86=0
- libnvjpeg=11.9.0.86=0
- libnvjpeg-dev=11.9.0.86=0
- libopus=1.3.1=h7b6447c_0
- libpng=1.6.37=hbc83047_0
- libpq=12.9=h16c4e8d_3
- libstdcxx-ng=11.2.0=h1234567_1
- libtasn1=4.16.0=h27cfd23_0
- libtiff=4.4.0=hecacb30_0
- libunistring=0.9.10=h27cfd23_0
- libuuid=2.32.1=h7f98852_1000
- libvpx=1.7.0=h439df22_0
- libwebp=1.2.4=h11a3e52_0
- libwebp-base=1.2.4=h5eee18b_0
- libxcb=1.15=h7f8727e_0
- libxkbcommon=1.0.3=he3ba5ed_0
- libxml2=2.9.14=h74e7548_0
- lz4-c=1.9.3=h295c915_1
- markupsafe=2.1.1=py39hb9d737c_1
- matplotlib-base=3.5.2=py39h700656a_0
- mkl=2021.4.0=h06a4308_640
- mkl-service=2.4.0=py39h7f8727e_0
- mkl_fft=1.3.1=py39hd3c417c_0
- mkl_random=1.2.2=py39h51133e4_0
- munkres=1.1.4=pyh9f0ad1d_0
- ncurses=6.3=h5eee18b_3
- nettle=3.7.3=hbbd107a_1
- nsight-compute=2022.3.0.22=0
- nspr=4.33=h295c915_0
- nss=3.74=h0370c37_0
- numpy=1.23.3=py39h14f4228_0
- numpy-base=1.23.3=py39h31eccc5_0
- openh264=2.1.1=h4ff587b_0
- openssl=1.1.1s=h7f8727e_0
- packaging=21.3=pyhd8ed1ab_0
- pcre=8.45=h9c3ff4c_0
- pillow=9.2.0=py39hace64e9_1
- pip=22.2.2=py39h06a4308_0
- pycparser=2.21=pyhd3eb1b0_0
- pyopenssl=22.0.0=pyhd3eb1b0_0
- pyparsing=3.0.9=pyhd8ed1ab_0
- pyqt=5.15.4=py39h5a03fae_0
- pyqt5-sip=12.9.0=py39h5a03fae_0
- pysocks=1.7.1=py39h06a4308_0
- python=3.9.13=haa1d7c7_2
- python-dateutil=2.8.2=pyhd8ed1ab_0
- python_abi=3.9=2_cp39
- pytorch-cuda=11.7=h67b0de4_0
- pytorch-mutex=1.0=cuda
- pytz=2022.6=pyhd8ed1ab_0
- pyyaml=6.0=py39hb9d737c_4
- qt-main=5.15.2=h327a75a_7
- readline=8.2=h5eee18b_0
- requests=2.28.1=py39h06a4308_0
- scikit-learn=1.1.3=py39h6a678d5_0
- setuptools=65.5.0=py39h06a4308_0
- shellingham=1.5.0=pyhd8ed1ab_0
- sip=6.5.1=py39he80948d_2
- six=1.16.0=pyhd3eb1b0_1
- smart_open=5.2.1=pyhd8ed1ab_0
- spacy-legacy=3.0.10=pyhd8ed1ab_0
- spacy-loggers=1.0.3=pyhd8ed1ab_0
- sqlite=3.39.3=h5082296_0
- threadpoolctl=3.1.0=pyh8a188c0_0
- tk=8.6.12=h1ccaba5_0
- toml=0.10.2=pyhd8ed1ab_0
- torchaudio=0.13.0=py39_cu117
- torchvision=0.14.0=py39_cu117
- tqdm=4.64.1=pyhd8ed1ab_0
- typer=0.4.2=pyhd8ed1ab_0
- typing-extensions=4.3.0=py39h06a4308_0
- typing_extensions=4.3.0=py39h06a4308_0
- tzdata=2022e=h04d1e81_0
- unicodedata2=14.0.0=py39hb9d737c_1
- urllib3=1.26.12=py39h06a4308_0
- wasabi=0.10.1=pyhd8ed1ab_1
- wheel=0.37.1=pyhd3eb1b0_0
- x264=1!157.20191217=h7b6447c_0
- xz=5.2.6=h5eee18b_0
- yaml=0.2.5=h7f98852_2
- zlib=1.2.13=h5eee18b_0
- zstd=1.5.2=ha4553b6_0
- pip:
- absl-py==1.3.0
- accelerate==0.13.2
- aiohttp==3.8.3
- aiosignal==1.2.0
- albumentations==1.3.0
- anyio==3.6.2
- argon2-cffi==21.3.0
- argon2-cffi-bindings==21.2.0
- arrow==1.2.3
- asttokens==2.1.0
- astunparse==1.6.3
- async-timeout==4.0.2
- attrs==22.1.0
- babel==2.10.3
- backcall==0.2.0
- backpack-for-pytorch==1.5.1
- beautifulsoup4==4.11.1
- bleach==5.0.1
- blis==0.7.9
- bokeh==3.0.2
- boto3==1.25.5
- botocore==1.28.5
- bravado==11.0.3
- bravado-core==5.17.1
- brotli==1.0.9
- cachetools==5.2.0
- captum==0.5.0
- catalyst==22.4
- comet-ml==3.31.16
- confection==0.0.3
- configobj==5.0.6
- contourpy==1.0.6
- cymem==2.0.7
- datasets==2.6.1
- debugpy==1.6.3
- decorator==5.1.1
- defusedxml==0.7.1
- diffusers==0.6.0
- dill==0.3.5.1
- docker-pycreds==0.4.0
- dulwich==0.20.50
- einops==0.6.0
- entrypoints==0.4
- everett==3.1.0
- execnb==0.1.4
- executing==1.2.0
- fastjsonschema==2.16.2
- filelock==3.8.0
- flask==2.2.2
- flask-compress==1.13
- fonttools==4.38.0
- fqdn==1.5.1
- frozenlist==1.3.1
- fsspec==2022.10.0
- ftfy==6.1.1
- future==0.18.2
- ghapi==1.0.3
- gitdb==4.0.9
- gitpython==3.1.29
- google-auth==2.14.0
- google-auth-oauthlib==0.4.6
- gputil==1.4.0
- grpcio==1.50.0
- huggingface-hub==0.10.1
- hydra-slayer==0.4.0
- imageio==2.22.3
- importlib-metadata==5.0.0
- ipykernel==6.17.0
- ipython==8.6.0
- ipython-genutils==0.2.0
- ipywidgets==8.0.2
- isoduration==20.11.0
- itsdangerous==2.1.2
- jedi==0.18.1
- jmespath==1.0.1
- json5==0.9.10
- jsonpointer==2.3
- jsonref==1.0.0.post1
- jsonschema==4.16.0
- jupyter-client==7.4.4
- jupyter-contrib-core==0.4.2
- jupyter-contrib-nbextensions==0.7.0
- jupyter-core==4.11.2
- jupyter-highlight-selected-word==0.2.0
- jupyter-nbextensions-configurator==0.6.1
- jupyter-server==1.21.0
- jupyter-server-proxy==3.2.2
- jupyterlab==3.5.0
- jupyterlab-nvdashboard==0.7.0
- jupyterlab-pygments==0.2.2
- jupyterlab-server==2.16.2
- jupyterlab-widgets==3.0.3
- jupyterthemes==0.20.0
- kiwisolver==1.4.4
- kornia==0.6.8
- lesscpy==0.15.1
- lxml==4.9.1
- markdown==3.4.1
- matplotlib==3.6.1
- matplotlib-inline==0.1.6
- mistune==2.0.4
- monotonic==1.6
- mpmath==1.2.1
- msgpack==1.0.4
- multidict==6.0.2
- multiprocess==0.70.13
- murmurhash==1.0.9
- mycolorpy==1.5.1
- nbclassic==0.4.7
- nbclient==0.7.0
- nbconvert==7.2.3
- nbdev==2.3.7
- nbformat==5.7.0
- neptune-client==0.16.11
- nest-asyncio==1.5.6
- networkx==2.8.7
- ninja==1.10.2.4
- notebook==6.5.2
- notebook-shim==0.2.0
- nvidia-cublas-cu11==11.10.3.66
- nvidia-cuda-nvrtc-cu11==11.7.99
- nvidia-cuda-runtime-cu11==11.7.99
- nvidia-cudnn-cu11==8.5.0.96
- oauthlib==3.2.2
- opencv-python==4.6.0.66
- opencv-python-headless==4.6.0.66
- pandas==1.5.1
- pandocfilters==1.5.0
- parso==0.8.3
- pathtools==0.1.2
- pathy==0.6.2
- pexpect==4.8.0
- pickleshare==0.7.5
- ply==3.11
- preshed==3.0.8
- prometheus-client==0.15.0
- promise==2.3
- prompt-toolkit==3.0.31
- protobuf==3.19.6
- psutil==5.9.3
- ptyprocess==0.7.0
- pure-eval==0.2.2
- pyarrow==10.0.0
- pyasn1==0.4.8
- pyasn1-modules==0.2.8
- pydantic==1.10.2
- pydeprecate==0.3.2
- pydicom==2.3.0
- pygments==2.13.0
- pyjwt==2.6.0
- pynvml==11.4.1
- pyrsistent==0.19.1
- pytorch-ignite==0.4.10
- pytorch-lightning==1.7.7
- pywavelets==1.4.1
- pyzmq==24.0.1
- qudida==0.0.4
- regex==2022.10.31
- requests-oauthlib==1.3.1
- requests-toolbelt==0.10.1
- responses==0.18.0
- rfc3339-validator==0.1.4
- rfc3987==1.3.8
- rsa==4.9
- s3transfer==0.6.0
- scikit-image==0.19.3
- scipy==1.9.3
- semantic-version==2.10.0
- send2trash==1.8.0
- sentencepiece==0.1.97
- sentry-sdk==1.10.1
- setproctitle==1.3.2
- shortuuid==1.0.9
- simpervisor==0.4
- simplejson==3.17.6
- smmap==5.0.0
- sniffio==1.3.0
- soupsieve==2.3.2.post1
- spacy==3.4.2
- srsly==2.4.5
- stack-data==0.6.0
- swagger-spec-validator==3.0.2
- sympy==1.11.1
- tensorboard==2.10.1
- tensorboard-data-server==0.6.1
- tensorboard-plugin-wit==1.8.1
- tensorboardx==2.5.1
- terminado==0.17.0
- thinc==8.1.5
- tifffile==2022.10.10
- timm==0.6.11
- tinycss2==1.2.1
- tokenizers==0.13.1
- tomli==2.0.1
- torch==1.12.1
- torcheval==0.0.5
- torchmetrics==0.10.2
- torchtnt==0.0.3
- tornado==6.2
- traitlets==5.5.0
- transformers==4.24.0
- uri-template==1.2.0
- wandb==0.13.4
- watchdog==2.1.9
- wcwidth==0.2.5
- webcolors==1.12
- webencodings==0.5.1
- websocket-client==1.3.3
- werkzeug==2.2.2
- widgetsnbextension==4.0.3
- wrapt==1.14.1
- wurlitzer==3.0.2
- wwf==0.0.16
- xxhash==3.1.0
- xyzservices==2022.9.0
- yarl==1.8.1
- zipp==3.10.0
prefix: /home/fredguth/.miniconda3/envs/py39
Hi Fred,
I don't know what in your environment caused the problem, but happy it's fixed. Feel free to close the issue.
Have a good one :) Felix
I got a different error:
# create an environment with python 3.9
conda create --name backpack-issue-294 python=3.9
# activate it
conda activate backpack-issue-294
# install dependencies
pip install backpack-for-pytorch==1.5.1 torch==1.12.1
# try importing
python -c "from backpack import backpack, extend"
#ok, that works, let's see...
python -c "from backpack import KFAC"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'KFAC' from 'backpack' (/home/fredguth/.miniconda3/envs/backpack-issue-294/lib/python3.9/site-packages/backpack/__init__.py)
I am trying to reproduce the example from `backpack.pt``
"""
Compute the gradient with Pytorch
and KFAC with BackPACK
"""
from torch.nn import CrossEntropyLoss, Linear
from utils import load_mnist_data
from backpack import extend, backpack, KFAC
X, y = load_mnist_data()
model = extend(Linear(784, 10))
lossfunc = extend(CrossEntropyLoss())
loss = lossfunc(model(X), y)
with backpack(KFAC()):
loss.backward()
for param in model.parameters():
print(param.grad)
print(param.kfac)
Ah yes, the examples on the splash page look out of date. Patch coming. It should be
from backpack import extend, backpack
from backpack.extensions import KFAC
Instead of
from backpack import extend, backpack, KFAC
See also #223.
Fixed by #298. Closing.
I am getting an error trying to run the code example from the site:
from backpack import backpack, extend
error:
ImportError: cannot import name 'backpack' from 'backpack' (unknown location)
torch.version = '1.12.1+cu102'