Skip to content

TypeError: 'int' object is not callable during torch model weights load #8

@MrCsabaToth

Description

@MrCsabaToth

I followed the README.

  1. Setup the conda env based on the environment.yaml
  2. Downloaded the weights.tar and also the two npy stat files
  3. Compiled and installed wgrib2
  4. Used gdas script to download data for a 2023 summer day
  5. Trying to call inference. I checked that the file is in the right place. With unzip -l it seems it's not corrupted but who knows.
fourcastnet) jupyter@instance-20250216-164054:~/FourCastNet/NCEP$ python inference.py 2023080400 -w model/ -i input_2023080400.npy -o output/ -l 336
model/weights.tar
Traceback (most recent call last):
  File "/home/jupyter/FourCastNet/NCEP/inference.py", line 265, in <module>
    fcn.run()
    ~~~~~~~^^
  File "/home/jupyter/FourCastNet/NCEP/inference.py", line 196, in run
    model = self.load_model(path)
  File "/home/jupyter/FourCastNet/NCEP/inference.py", line 158, in load_model
    checkpoint = torch.load(checkpoint_file, map_location=device)
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/serialization.py", line 1462, in load
    return _load(
        opened_zipfile,
    ...<3 lines>...
        **pickle_load_args,
    )
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/serialization.py", line 1964, in _load
    result = unpickler.load()
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/_weights_only_unpickler.py", line 512, in load
    self.append(self.persistent_load(pid))
                ~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/serialization.py", line 1928, in persistent_load
    typed_storage = load_tensor(
        dtype, nbytes, key, _maybe_decode_ascii(location)
    )
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/serialization.py", line 1900, in load_tensor
    wrap_storage=restore_location(storage, location),
                 ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/fourcastnet/lib/python3.13/site-packages/torch/serialization.py", line 1811, in restore_location
    result = map_location(storage, location)
TypeError: 'int' object is not callable

This is a blocker right now.

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