facebookresearch / esm

Evolutionary Scale Modeling (esm): Pretrained language models for proteins
MIT License
3.26k stars 643 forks source link

Error at downloading esm_msa1b_t12_100M_UR50S model #168

Closed etiur closed 2 years ago

etiur commented 2 years ago

Description I am trying to get the pretrained models to generate features for my machine learning models so I wanted to download both esm1b_t33_650M_UR50S and esm_msa1b_t12_100M_UR50S. I had no problems with ESM1b but when downloading MSA-ESM1b it gave error. I tried both functions

model, alphabet = torch.hub.load("facebookresearch/esm:main", "esm_msa1b_t12_100M_UR50S") msa_transformer, msa_alphabet = esm.pretrained.esm_msa1b_t12_100M_UR50S()

Version This is the pytorch version I am using, and in the requirements only said pytorch >= 1.5

import torch torch.version '1.9.0.post2'

Logs This is the error that appears

Downloading: "https://dl.fbaipublicfiles.com/fair-esm/models/esm_msa1b_t12_100M_UR50S.pt" to /home/ruite/.cache/torch/checkpoints/esm_msa1b_t12_100M_UR50S.pt Traceback (most recent call last): File "/home/ruite/.cache/torch/hub/facebookresearch_esm_main/esm/pretrained.py", line 29, in load_hub_workaround data = torch.hub.load_state_dict_from_url(url, progress=False, map_location="cpu") File "/home/ruite/anaconda3/envs/enzyminer/lib/python3.6/site-packages/torch/hub.py", line 501, in load_state_dict_from_url

RuntimeError: Only one file(not dir) is allowed in the zipfile

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/ruite/anaconda3/envs/enzyminer/lib/python3.6/code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in File "/home/ruite/.cache/torch/hub/facebookresearch_esm_main/esm/pretrained.py", line 215, in esm_msa1b_t12_100M_UR50S return load_model_and_alphabet_hub("esm_msa1b_t12_100M_UR50S") File "/home/ruite/.cache/torch/hub/facebookresearch_esm_main/esm/pretrained.py", line 50, in load_model_and_alphabet_hub model_data = load_hub_workaround(url) File "/home/ruite/.cache/torch/hub/facebookresearch_esm_main/esm/pretrained.py", line 34, in load_hub_workaround f"{torch.hub.get_dir()}/checkpoints/{fn}", AttributeError: module 'torch.hub' has no attribute 'get_dir'

tomsercu commented 2 years ago

Hi, thanks for your question! This is due to a bug introduced in torch hub loading (https://github.com/pytorch/pytorch/issues/43106). We actually have a workaround in https://github.com/facebookresearch/esm/blob/main/esm/pretrained.py#L27-L39 So with the latest version on current esm main branch, this should be resolved.

tomsercu commented 2 years ago

feel free to re-open if updating esm doesn't resolve the issue.