facebookresearch / esm

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

cannot import name 'esm_if1_gvp4_t16_142M_UR50' #220

Closed ElArkk closed 2 years ago

ElArkk commented 2 years ago

Bug description One model defined in pretrained.py makes loading any model from the torch hub fail.

Reproduction steps Run torch.hub.load("facebookresearch/esm:main", "esm1v_t33_650M_UR90S_1")

Expected behavior We'd expect the model to be downloaded.

Logs Please paste the command line output:

File /opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py:404, in load(repo_or_dir, model, source, force_reload, verbose, skip_validation, *args, **kwargs)
    [401](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=400) if source == 'github':
    [402](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=401)     repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose, skip_validation)
--> [404](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=403) model = _load_local(repo_or_dir, model, *args, **kwargs)
    [405](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=404) return model

File /opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py:430, in _load_local(hubconf_dir, model, *args, **kwargs)
    [427](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=426) sys.path.insert(0, hubconf_dir)
    [429](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=428) hubconf_path = os.path.join(hubconf_dir, MODULE_HUBCONF)
--> [430](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=429) hub_module = _import_module(MODULE_HUBCONF, hubconf_path)
    [432](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=431) entry = _load_entry_from_hubconf(hub_module, model)
    [433](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=432) model = entry(*args, **kwargs)

File /opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py:76, in _import_module(name, path)
     [74](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=73) module = importlib.util.module_from_spec(spec)
     [75](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=74) assert isinstance(spec.loader, Loader)
---> [76](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=75) spec.loader.exec_module(module)
     [77](file:///opt/install/conda/envs/env/lib/python3.9/site-packages/torch/hub.py?line=76) return module

File <frozen importlib._bootstrap_external>:850, in exec_module(self, module)

File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)

File ~/.cache/torch/hub/facebookresearch_esm_main/hubconf.py:8, in <module>
      [1](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=0) # Copyright (c) Facebook, Inc. and its affiliates.
      [2](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=1) #
      [3](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=2) # This source code is licensed under the MIT license found in the
      [4](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=3) # LICENSE file in the root directory of this source tree.
      [6](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=5) dependencies = ["torch"]
----> [8](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=7) from esm.pretrained import (
      [9](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=8)     esm1_t34_670M_UR50S,
     [10](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=9)     esm1_t34_670M_UR50D,
     [11](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=10)     esm1_t34_670M_UR100,
     [12](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=11)     esm1_t12_85M_UR50S,
     [13](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=12)     esm1_t6_43M_UR50S,
     [14](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=13)     esm1b_t33_650M_UR50S,
     [15](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=14)     esm_msa1_t12_100M_UR50S,
     [16](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=15)     esm_msa1b_t12_100M_UR50S,
     [17](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=16)     esm1v_t33_650M_UR90S,
     [18](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=17)     esm1v_t33_650M_UR90S_1,
     [19](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=18)     esm1v_t33_650M_UR90S_2,
     [20](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=19)     esm1v_t33_650M_UR90S_3,
     [21](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=20)     esm1v_t33_650M_UR90S_4,
     [22](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=21)     esm1v_t33_650M_UR90S_5,
     [23](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=22)     esm_if1_gvp4_t16_142M_UR50,
     [24](file:///home/username/.cache/torch/hub/facebookresearch_esm_main/hubconf.py?line=23) )

ImportError: cannot import name 'esm_if1_gvp4_t16_142M_UR50' from 'esm.pretrained' (/opt/install/conda/envs/env/lib/python3.9/site-packages/esm/pretrained.py)
tomsercu commented 2 years ago

Thanks for flagging, the problem looks like /opt/install/conda/envs/env/lib/python3.9/site-packages/esm is being picked up which doesn't have the latest model yet. You could either try pip uninstall fair-esm, or install the latest esm via pip install git+https://github.com/facebookresearch/esm.git We should release with the inverse folding model as v0.5.0 soon :)

ElArkk commented 2 years ago

Installing from GitHub did the trick, thanks! :)