Skip to content

Some code and model path errors. #7

Description

@duaghk

Dear author.

Hello.

Thanks for your nice tools.

When I using ERGO-II, I found some errors in code.

  1. TCR ae model location error.
_python3 ./Predict.py vdjdb ./example.csv 
/usr/local/lib/python3.8/dist-packages/pytorch_lightning/core/decorators.py:13: UserWarning: data_loader decorator deprecated in 0.7.0. Will remove 0.9.0
  warnings.warn(w)
Traceback (most recent call last):
  File "./Predict.py", line 104, in <module>
    df = predict(sys.argv[1], sys.argv[2])
  File "./Predict.py", line 86, in predict
    model, train_file = get_model(dataset)
  File "./Predict.py", line 72, in get_model
    model = load_model(hparams, checkpoint)
  File "./Predict.py", line 43, in load_model
    model = ERGOLightning(hparams)
  File "/opt/ERGO-II/Trainer.py", line 49, in __init__
    self.tcra_encoder = AE_Encoder(encoding_dim=self.encoding_dim, tcr_type='alpha', max_len=34)
  File "/opt/ERGO-II/Models.py", line 102, in __init__
    self.init_ae_params(train_ae)
  File "/opt/ERGO-II/Models.py", line 110, in init_ae_params
    checkpoint = torch.load(ae_file)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 525, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 212, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 193, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'TCR_Autoencoder/tcra_ae_dim_100.pt'

so, I copy the directory.
( in ERGO2 directory:) cp -r ./Models/AE ./TCR_Autoencoder
and it works well.

  1. Torch CPU-only error.
python3 ./Predict.py vdjdb ./example.csv 
/usr/local/lib/python3.8/dist-packages/pytorch_lightning/core/decorators.py:13: UserWarning: data_loader decorator deprecated in 0.7.0. Will remove 0.9.0
  warnings.warn(w)
Traceback (most recent call last):
  File "./Predict.py", line 105, in <module>
    df = predict(sys.argv[1], sys.argv[2])
  File "./Predict.py", line 87, in predict
    model, train_file = get_model(dataset)
  File "./Predict.py", line 73, in get_model
    model = load_model(hparams, checkpoint)
  File "./Predict.py", line 43, in load_model
    model = ERGOLightning(hparams)
  File "/opt/ERGO-II/Trainer.py", line 49, in __init__
    self.tcra_encoder = AE_Encoder(encoding_dim=self.encoding_dim, tcr_type='alpha', max_len=34)
  File "/opt/ERGO-II/Models.py", line 102, in __init__
    self.init_ae_params(train_ae)
  File "/opt/ERGO-II/Models.py", line 110, in init_ae_params
    checkpoint = torch.load(ae_file)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 529, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 702, in _legacy_load
    result = unpickler.load()
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 665, in persistent_load
    deserialized_objects[root_key] = restore_location(obj, location)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 156, in default_restore_location
    result = fn(storage, location)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 132, in _cuda_deserialize
    device = validate_cuda_device(location)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 116, in validate_cuda_device
    raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

I used CPU-only machine, and torch need to set map_locations.
in ERGO-II/Models.py : checkpoint = torch.load(ae_file) -> checkpoint = torch.load(ae_file, map_location=torch.device('cpu' ))
it works well.

I wish it will be helpful.

Best regards.

Jeongjun Chae

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions