Skip to content

TypeError: 'weights_only' when deploying checkpoint to LAMMPS using PyTorch 1.12.0 #205

@samueldyoung29ctr

Description

@samueldyoung29ctr

Dear SevenNet Developers,

I'm excited to try out your model and checkpoints, but am running into a TypeError when trying to convert one of the publicly available checkpoints to a LAMMPS serial potential. I installed sevenn along with a supporting Conda environment, trying to install as many dependencies as possible from conda-forge.

I am on a cluster limited to CUDA 11.6, so I installed PyTorch 1.12.0+cu116, as this is one of the recommended versions. PyTorch 1.12 supports at most Python 3.10, so I installed that version.

Problem

I tried deploying the 7net-mf-ompa checkpoint to a LAMMPS potential, trying both of these commands:

# Deploying from checkpoint path
sevenn_get_model ./checkpoint_sevennet_mf_ompa.pth

# Deploying from checkpoint name
sevenn_get_model 7net-mf-ompa

Both of these result in a TypeError around an unexpected weights_only argument to pickle.Unpickler:

Traceback (most recent call last):
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/bin/sevenn_get_model", line 8, in <module>
    sys.exit(main())
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/main/sevenn_get_model.py", line 60, in main
    run(args)
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/main/sevenn_get_model.py", line 38, in run
    deploy(checkpoint_path, output_prefix, modal)
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/scripts/deploy.py", line 27, in deploy
    model, config = cp.build_model('e3nn'), cp.config
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/checkpoint.py", line 297, in build_model
    cp_using_cue = self.config[KEY.CUEQUIVARIANCE_CONFIG]['use']
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/checkpoint.py", line 223, in config
    self._load()
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/sevenn/checkpoint.py", line 272, in _load
    cp = torch_load(cp_path, weights_only=False, map_location='cpu')
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/torch/serialization.py", line 712, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/home/user/.conda/envs/sevenn-pytorch-cu116/lib/python3.10/site-packages/torch/serialization.py", line 1047, in _load
    unpickler = UnpicklerWrapper(data_file, **pickle_load_args)
TypeError: 'weights_only' is an invalid keyword argument for Unpickler()

Environment and versions

  • Python: 3.10, installed from conda-forge.
  • Available CUDA version: 11.6.
  • Target GPUs: NVidia A40, A100.
  • PyTorch: 1.12.0+cu116, installed from pip using --index-url https://download.pytorch.org/whl/cu116
  • sevnn: 0.11.0, installed from pip.
Conda environment
List of packages in environment: "/home/user/.conda/envs/sevenn-pytorch-cu116"

  Name                       Version       Build                 Channel    
──────────────────────────────────────────────────────────────────────────────
  _libgcc_mutex              0.1           conda_forge           conda-forge
  _openmp_mutex              4.5           2_gnu                 conda-forge
  aiohappyeyeballs           2.6.1         pyhd8ed1ab_0          conda-forge
  aiohttp                    3.11.16       py310h89163eb_0       conda-forge
  aiosignal                  1.3.2         pyhd8ed1ab_0          conda-forge
  alsa-lib                   1.2.14        hb9d3cd8_0            conda-forge
  annotated-types            0.7.0         pyhd8ed1ab_1          conda-forge
  appdirs                    1.4.4         pyhd8ed1ab_1          conda-forge
  ase                        3.25.0        pyhd8ed1ab_0          conda-forge
  asttokens                  3.0.0         pyhd8ed1ab_1          conda-forge
  async-timeout              5.0.1         pyhd8ed1ab_1          conda-forge
  attrs                      25.3.0        pyh71513ae_0          conda-forge
  blinker                    1.9.0         pyhff2d567_0          conda-forge
  braceexpand                0.1.7         pyhd8ed1ab_1          conda-forge
  brotli                     1.1.0         hb9d3cd8_2            conda-forge
  brotli-bin                 1.1.0         hb9d3cd8_2            conda-forge
  brotli-python              1.1.0         py310hf71b8c6_2       conda-forge
  bzip2                      1.0.8         h4bc722e_7            conda-forge
  ca-certificates            2025.1.31     hbcca054_0            conda-forge
  cairo                      1.18.4        h3394656_0            conda-forge
  certifi                    2025.1.31     pyhd8ed1ab_0          conda-forge
  cffi                       1.17.1        py310h8deb56e_0       conda-forge
  charset-normalizer         3.4.1         pyhd8ed1ab_0          conda-forge
  click                      8.1.8         pyh707e725_0          conda-forge
  colorama                   0.4.6         pyhd8ed1ab_1          conda-forge
  comm                       0.2.2         pyhd8ed1ab_1          conda-forge
  contourpy                  1.3.2         py310h3788b33_0       conda-forge
  cpython                    3.10.17       py310hd8ed1ab_0       conda-forge
  cycler                     0.12.1        pyhd8ed1ab_1          conda-forge
  cyrus-sasl                 2.1.27        h54b06d7_7            conda-forge
  dbus                       1.13.6        h5008d03_3            conda-forge
  debugpy                    1.8.14        py310hf71b8c6_0       conda-forge
  decorator                  5.2.1         pyhd8ed1ab_0          conda-forge
  docker-pycreds             0.4.0         py_0                  conda-forge
  double-conversion          3.3.1         h5888daf_0            conda-forge
  eval_type_backport         0.2.2         pyha770c72_0          conda-forge
  exceptiongroup             1.2.2         pyhd8ed1ab_1          conda-forge
  executing                  2.1.0         pyhd8ed1ab_1          conda-forge
  expat                      2.7.0         h5888daf_0            conda-forge
  flask                      3.1.0         pyhd8ed1ab_1          conda-forge
  font-ttf-dejavu-sans-mono  2.37          hab24e00_0            conda-forge
  font-ttf-inconsolata       3.000         h77eed37_0            conda-forge
  font-ttf-source-code-pro   2.038         h77eed37_0            conda-forge
  font-ttf-ubuntu            0.83          h77eed37_3            conda-forge
  fontconfig                 2.15.0        h7e30c49_1            conda-forge
  fonts-conda-ecosystem      1             0                     conda-forge
  fonts-conda-forge          1             0                     conda-forge
  fonttools                  4.57.0        py310h89163eb_0       conda-forge
  freetype                   2.13.3        h48d6fc4_0            conda-forge
  frozenlist                 1.5.0         py310h89163eb_1       conda-forge
  fsspec                     2025.3.2      pyhd8ed1ab_0          conda-forge
  future                     1.0.0         pyhd8ed1ab_2          conda-forge
  gitdb                      4.0.12        pyhd8ed1ab_0          conda-forge
  gitpython                  3.1.44        pyhff2d567_0          conda-forge
  gmp                        6.3.0         hac33072_2            conda-forge
  gmpy2                      2.1.5         py310he8512ff_3       conda-forge
  graphite2                  1.3.13        h59595ed_1003         conda-forge
  h2                         4.2.0         pyhd8ed1ab_0          conda-forge
  harfbuzz                   11.0.1        h2c12942_0            conda-forge
  hpack                      4.1.0         pyhd8ed1ab_0          conda-forge
  hyperframe                 6.1.0         pyhd8ed1ab_0          conda-forge
  icu                        75.1          he02047a_0            conda-forge
  idna                       3.10          pyhd8ed1ab_1          conda-forge
  importlib-metadata         8.6.1         pyha770c72_0          conda-forge
  importlib-resources        6.5.2         pyhd8ed1ab_0          conda-forge
  importlib_resources        6.5.2         pyhd8ed1ab_0          conda-forge
  ipykernel                  6.29.5        pyh3099207_0          conda-forge
  ipython                    8.35.0        pyh907856f_0          conda-forge
  ipython_pygments_lexers    1.1.1         pyhd8ed1ab_0          conda-forge
  ipywidgets                 8.1.6         pyhd8ed1ab_0          conda-forge
  itsdangerous               2.2.0         pyhd8ed1ab_1          conda-forge
  jedi                       0.19.2        pyhd8ed1ab_1          conda-forge
  jinja2                     3.1.6         pyhd8ed1ab_0          conda-forge
  joblib                     1.4.2         pyhd8ed1ab_1          conda-forge
  jupyter_client             8.6.3         pyhd8ed1ab_1          conda-forge
  jupyter_core               5.7.2         pyh31011fe_1          conda-forge
  jupyterlab_widgets         3.0.14        pyhd8ed1ab_0          conda-forge
  keyutils                   1.6.1         h166bdaf_0            conda-forge
  kiwisolver                 1.4.7         py310h3788b33_0       conda-forge
  krb5                       1.21.3        h659f571_0            conda-forge
  latexcodec                 2.0.1         pyh9f0ad1d_0          conda-forge
  lcms2                      2.17          h717163a_0            conda-forge
  ld_impl_linux-64           2.43          h712a8e2_4            conda-forge
  lerc                       4.0.0         h27087fc_0            conda-forge
  libabseil                  20250127.1    cxx17_hbbce691_0      conda-forge
  libblas                    3.9.0         31_h59b9bed_openblas  conda-forge
  libbrotlicommon            1.1.0         hb9d3cd8_2            conda-forge
  libbrotlidec               1.1.0         hb9d3cd8_2            conda-forge
  libbrotlienc               1.1.0         hb9d3cd8_2            conda-forge
  libcblas                   3.9.0         31_he106b2a_openblas  conda-forge
  libclang-cpp20.1           20.1.2        default_hb5137d0_0    conda-forge
  libclang13                 20.1.2        default_h9c6a7e4_0    conda-forge
  libcups                    2.3.3         h4637d8d_4            conda-forge
  libdeflate                 1.23          h4ddbbb0_0            conda-forge
  libdrm                     2.4.124       hb9d3cd8_0            conda-forge
  libedit                    3.1.20250104  pl5321h7949ede_0      conda-forge
  libegl                     1.7.0         ha4b6fd6_2            conda-forge
  libexpat                   2.7.0         h5888daf_0            conda-forge
  libffi                     3.4.6         h2dba641_1            conda-forge
  libgcc                     14.2.0        h767d61c_2            conda-forge
  libgcc-ng                  14.2.0        h69a702a_2            conda-forge
  libgfortran                14.2.0        h69a702a_2            conda-forge
  libgfortran5               14.2.0        hf1ad2bd_2            conda-forge
  libgl                      1.7.0         ha4b6fd6_2            conda-forge
  libglib                    2.84.1        h2ff4ddf_0            conda-forge
  libglvnd                   1.7.0         ha4b6fd6_2            conda-forge
  libglx                     1.7.0         ha4b6fd6_2            conda-forge
  libgomp                    14.2.0        h767d61c_2            conda-forge
  libiconv                   1.18          h4ce23a2_1            conda-forge
  libjpeg-turbo              3.0.0         hd590300_1            conda-forge
  liblapack                  3.9.0         31_h7ac8fdf_openblas  conda-forge
  libllvm20                  20.1.3        he9d0ab4_0            conda-forge
  liblzma                    5.8.1         hb9d3cd8_0            conda-forge
  libmpdec                   4.0.0         h4bc722e_0            conda-forge
  libnsl                     2.0.1         hd590300_0            conda-forge
  libntlm                    1.8           hb9d3cd8_0            conda-forge
  libopenblas                0.3.29        pthreads_h94d23a6_0   conda-forge
  libopengl                  1.7.0         ha4b6fd6_2            conda-forge
  libpciaccess               0.18          hd590300_0            conda-forge
  libpng                     1.6.47        h943b412_0            conda-forge
  libpq                      17.4          h27ae623_1            conda-forge
  libsodium                  1.0.20        h4ab18f5_0            conda-forge
  libsqlite                  3.49.1        hee588c1_2            conda-forge
  libstdcxx                  14.2.0        h8f9b012_2            conda-forge
  libstdcxx-ng               14.2.0        h4852527_2            conda-forge
  libtiff                    4.7.0         hd9ff511_3            conda-forge
  libuuid                    2.38.1        h0b41bf4_0            conda-forge
  libwebp-base               1.5.0         h851e524_0            conda-forge
  libxcb                     1.17.0        h8a09558_0            conda-forge
  libxcrypt                  4.4.36        hd590300_1            conda-forge
  libxkbcommon               1.8.1         hc4a0caf_0            conda-forge
  libxml2                    2.13.7        h4bc477f_1            conda-forge
  libxslt                    1.1.39        h76b75d6_0            conda-forge
  libzlib                    1.3.1         hb9d3cd8_2            conda-forge
  looseversion               1.3.0         pyhd8ed1ab_0          conda-forge
  lxml                       5.3.2         py310h490dddc_0       conda-forge
  markupsafe                 3.0.2         py310h89163eb_1       conda-forge
  matplotlib                 3.10.1        py310hff52083_0       conda-forge
  matplotlib-base            3.10.1        py310h68603db_0       conda-forge
  matplotlib-inline          0.1.7         pyhd8ed1ab_1          conda-forge
  matscipy                   1.1.0         py310h5eaa309_2       conda-forge
  monty                      2025.3.3      pyhd8ed1ab_0          conda-forge
  mpc                        1.3.1         h24ddda3_1            conda-forge
  mpfr                       4.2.1         h90cbb55_3            conda-forge
  mpmath                     1.3.0         pyhd8ed1ab_1          conda-forge
  multidict                  6.3.2         py310h89163eb_0       conda-forge
  munkres                    1.1.4         pyh9f0ad1d_0          conda-forge
  mysql-common               9.2.0         h266115a_0            conda-forge
  mysql-libs                 9.2.0         he0572af_0            conda-forge
  narwhals                   1.35.0        pyh29332c3_0          conda-forge
  natsort                    8.4.0         pyh29332c3_1          conda-forge
  ncurses                    6.5           h2d0b736_3            conda-forge
  nest-asyncio               1.6.0         pyhd8ed1ab_1          conda-forge
  networkx                   3.4.2         pyh267e887_2          conda-forge
  numpy                      2.2.4         py310hefbff90_0       conda-forge
  openjpeg                   2.5.3         h5fbd93e_0            conda-forge
  openldap                   2.6.9         he970967_0            conda-forge
  openssl                    3.5.0         h7b32b05_0            conda-forge
  opt_einsum                 3.4.0         pyhd8ed1ab_1          conda-forge
  packaging                  24.2          pyhd8ed1ab_2          conda-forge
  palettable                 3.3.3         pyhd8ed1ab_1          conda-forge
  pandas                     2.2.3         py310h5eaa309_3       conda-forge
  parso                      0.8.4         pyhd8ed1ab_1          conda-forge
  patsy                      1.0.1         pyhd8ed1ab_1          conda-forge
  pcre2                      10.44         hba22ea6_2            conda-forge
  pexpect                    4.9.0         pyhd8ed1ab_1          conda-forge
  pickleshare                0.7.5         pyhd8ed1ab_1004       conda-forge
  pillow                     11.1.0        py310h7e6dc6c_0       conda-forge
  pip                        25.0.1        pyh8b19718_0          conda-forge
  pixman                     0.44.2        h29eaf8c_0            conda-forge
  platformdirs               4.3.7         pyh29332c3_0          conda-forge
  plotly                     6.0.1         pyhd8ed1ab_0          conda-forge
  prompt-toolkit             3.0.51        pyha770c72_0          conda-forge
  propcache                  0.3.1         py310h89163eb_0       conda-forge
  protobuf                   5.29.3        py310hcba5963_0       conda-forge
  psutil                     7.0.0         py310ha75aee5_0       conda-forge
  pthread-stubs              0.4           hb9d3cd8_1002         conda-forge
  ptyprocess                 0.7.0         pyhd8ed1ab_1          conda-forge
  pure_eval                  0.2.3         pyhd8ed1ab_1          conda-forge
  pybtex                     0.24.0        pyhd8ed1ab_3          conda-forge
  pycparser                  2.22          pyh29332c3_1          conda-forge
  pydantic                   2.11.3        pyh3cfb1c2_0          conda-forge
  pydantic-core              2.33.1        py310hc1293b2_0       conda-forge
  pygments                   2.19.1        pyhd8ed1ab_0          conda-forge
  pymatgen                   2025.4.17     py310hf462985_0       conda-forge
  pyparsing                  3.2.3         pyhd8ed1ab_1          conda-forge
  pyside6                    6.9.0         py310hfd10a26_0       conda-forge
  pysocks                    1.7.1         pyha55dd90_7          conda-forge
  python                     3.10.17       hd6af730_0_cpython    conda-forge
  python-dateutil            2.9.0.post0   pyhff2d567_1          conda-forge
  python-tzdata              2025.2        pyhd8ed1ab_0          conda-forge
  python_abi                 3.10          6_cp310               conda-forge
  pytz                       2025.2        pyhd8ed1ab_0          conda-forge
  pyyaml                     6.0.2         py310h89163eb_2       conda-forge
  pyzmq                      26.4.0        py310h71f11fc_0       conda-forge
  qhull                      2020.2        h434a139_5            conda-forge
  qt6-main                   6.9.0         h6441bc3_1            conda-forge
  readline                   8.2           h8c095d6_2            conda-forge
  requests                   2.32.3        pyhd8ed1ab_1          conda-forge
  ruamel.yaml                0.18.10       py310ha75aee5_0       conda-forge
  ruamel.yaml.clib           0.2.8         py310ha75aee5_1       conda-forge
  scikit-learn               1.6.1         py310h27f47ee_0       conda-forge
  scipy                      1.15.2        py310h1d65ade_0       conda-forge
  seaborn                    0.13.2        hd8ed1ab_3            conda-forge
  seaborn-base               0.13.2        pyhd8ed1ab_3          conda-forge
  sentry-sdk                 2.26.1        pyhd8ed1ab_0          conda-forge
  setproctitle               1.3.5         py310ha75aee5_0       conda-forge
  setuptools                 78.1.0        pyhff2d567_0          conda-forge
  sevenn                     0.11.0        pypi_0                pypi       
  six                        1.17.0        pyhd8ed1ab_0          conda-forge
  smmap                      5.0.2         pyhd8ed1ab_0          conda-forge
  spglib                     2.6.0         py310h1e9006d_0       conda-forge
  stack_data                 0.6.3         pyhd8ed1ab_1          conda-forge
  statsmodels                0.14.4        py310hf462985_0       conda-forge
  sympy                      1.13.3        pyh2585a3b_105        conda-forge
  tabulate                   0.9.0         pyhd8ed1ab_2          conda-forge
  threadpoolctl              3.6.0         pyhecae5ae_0          conda-forge
  tk                         8.6.13        noxft_h4845f30_101    conda-forge
  torch                      1.12.0+cu116  pypi_0                pypi       
  torchaudio                 0.12.0+cu116  pypi_0                pypi       
  torchvision                0.13.0+cu116  pypi_0                pypi       
  tornado                    6.4.2         py310ha75aee5_0       conda-forge
  tqdm                       4.67.1        pyhd8ed1ab_1          conda-forge
  traitlets                  5.14.3        pyhd8ed1ab_1          conda-forge
  typing                     3.10.0.0      pyhd8ed1ab_2          conda-forge
  typing-extensions          4.13.2        h0e9735f_0            conda-forge
  typing-inspection          0.4.0         pyhd8ed1ab_0          conda-forge
  typing_extensions          4.13.2        pyh29332c3_0          conda-forge
  tzdata                     2025b         h78e105d_0            conda-forge
  uncertainties              3.2.2         pyhd8ed1ab_2          conda-forge
  unicodedata2               16.0.0        py310ha75aee5_0       conda-forge
  urllib3                    2.4.0         pyhd8ed1ab_0          conda-forge
  wandb                      0.19.9        py310h69e60fc_0       conda-forge
  wayland                    1.23.1        h3e06ad9_0            conda-forge
  wcwidth                    0.2.13        pyhd8ed1ab_1          conda-forge
  werkzeug                   3.1.3         pyhd8ed1ab_1          conda-forge
  wheel                      0.45.1        pyhd8ed1ab_1          conda-forge
  widgetsnbextension         4.0.14        pyhd8ed1ab_0          conda-forge
  xcb-util                   0.4.1         hb711507_2            conda-forge
  xcb-util-cursor            0.1.5         hb9d3cd8_0            conda-forge
  xcb-util-image             0.4.0         hb711507_2            conda-forge
  xcb-util-keysyms           0.4.1         hb711507_0            conda-forge
  xcb-util-renderutil        0.3.10        hb711507_0            conda-forge
  xcb-util-wm                0.4.2         hb711507_0            conda-forge
  xkeyboard-config           2.43          hb9d3cd8_0            conda-forge
  xorg-libice                1.1.2         hb9d3cd8_0            conda-forge
  xorg-libsm                 1.2.6         he73a12e_0            conda-forge
  xorg-libx11                1.8.12        h4f16b4b_0            conda-forge
  xorg-libxau                1.0.12        hb9d3cd8_0            conda-forge
  xorg-libxcomposite         0.4.6         hb9d3cd8_2            conda-forge
  xorg-libxcursor            1.2.3         hb9d3cd8_0            conda-forge
  xorg-libxdamage            1.1.6         hb9d3cd8_0            conda-forge
  xorg-libxdmcp              1.1.5         hb9d3cd8_0            conda-forge
  xorg-libxext               1.3.6         hb9d3cd8_0            conda-forge
  xorg-libxfixes             6.0.1         hb9d3cd8_0            conda-forge
  xorg-libxi                 1.8.2         hb9d3cd8_0            conda-forge
  xorg-libxrandr             1.5.4         hb9d3cd8_0            conda-forge
  xorg-libxrender            0.9.12        hb9d3cd8_0            conda-forge
  xorg-libxtst               1.2.5         hb9d3cd8_3            conda-forge
  xorg-libxxf86vm            1.1.6         hb9d3cd8_0            conda-forge
  yaml                       0.2.5         h7f98852_2            conda-forge
  yarl                       1.18.3        py310h89163eb_1       conda-forge
  zeromq                     4.3.5         h3b0a872_7            conda-forge
  zipp                       3.21.0        pyhd8ed1ab_1          conda-forge
  zstandard                  0.23.0        py310ha75aee5_1       conda-forge
  zstd                       1.5.7         hb8e6e7a_2            conda-forge

Possible causes

The problem appears to arise from my version of torch.serialization.load not supporting the weights_only argument and improperly passing it along to pickle.Unpickler. One source recommends downgrading torch to 1.12 (which is what I'm running currently), but it looks like weights_only only became available in PyTorch 1.13.

Is it correct that PyTorch/1.12.0 + CUDA/11.6.2 is no longer a supported environment for SevenNet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions