Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_pretrained() Error. Cannot use a path to import local model? #132

Open
1830416002 opened this issue Oct 28, 2024 · 5 comments
Open

Comments

@1830416002
Copy link

my code like this:

model = ESM3.from_pretrained(model_name = "./huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/snapshots/66ecd636588d3100e13598a5720678db6583d01c/", device=torch.device("cpu"))

and give the error:
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [27], line 1
----> 1 model = ESM3.from_pretrained(model_name = "./huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/snapshots/66ecd636588d3100e13598a5720678db6583d01c/", device=torch.device("cpu"))

File ~/users/wtt/anaconda3/envs/esm3/lib/python3.11/site-packages/esm/models/esm3.py:251, in ESM3.from_pretrained(cls, model_name, device)
249 if device is None:
250 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
--> 251 model = load_local_model(model_name, device=device)
252 if device.type != "cpu":
253 model = model.to(torch.bfloat16)

File ~/users/wtt/anaconda3/envs/esm3/lib/python3.11/site-packages/esm/pretrained.py:87, in load_local_model(model_name, device)
83 def load_local_model(
84 model_name: str, device: torch.device = torch.device("cpu")
85 ) -> nn.Module:
86 if model_name not in LOCAL_MODEL_REGISTRY:
---> 87 raise ValueError(f"Model {model_name} not found in local model registry.")
88 return LOCAL_MODEL_REGISTRYmodel_name

ValueError: Model ./huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/snapshots/66ecd636588d3100e13598a5720678db6583d01c/ not found in local model registry.`

@Jaychonuo
Copy link

you may further refer .../66ecd636588d3100e13598a5720678db6583d01c/data

@1830416002
Copy link
Author

I have tried and have same error:
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [2], line 1
----> 1 model = ESM3.from_pretrained(model_name = "./huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/snapshots/66ecd636588d3100e13598a5720678db6583d01c/data", device=torch.device("cpu"))

File ~/users/wtt/anaconda3/envs/esm3/lib/python3.11/site-packages/esm/models/esm3.py:251, in ESM3.from_pretrained(cls, model_name, device)
249 if device is None:
250 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
--> 251 model = load_local_model(model_name, device=device)
252 if device.type != "cpu":
253 model = model.to(torch.bfloat16)

File ~/users/wtt/anaconda3/envs/esm3/lib/python3.11/site-packages/esm/pretrained.py:87, in load_local_model(model_name, device)
83 def load_local_model(
84 model_name: str, device: torch.device = torch.device("cpu")
85 ) -> nn.Module:
86 if model_name not in LOCAL_MODEL_REGISTRY:
---> 87 raise ValueError(f"Model {model_name} not found in local model registry.")
88 return LOCAL_MODEL_REGISTRYmodel_name

ValueError: Model ./huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/snapshots/66ecd636588d3100e13598a5720678db6583d01c/data not found in local model registry.`

@LHucass
Copy link

LHucass commented Nov 8, 2024

The same question for me
My remote server could not get connection with Internet so I must load the local model.

@Jaychonuo
Copy link

The same question for me My remote server could not get connection with Internet so I must load the local model.

https://blog.csdn.net/m0_61474277/article/details/140348032
for reference

@ebetica
Copy link
Contributor

ebetica commented Nov 11, 2024

This is the set of model names that the function supports: https://github.com/evolutionaryscale/esm/blob/main/esm/utils/constants/models.py#L2-L8

If you're looking to download it without internet, I think you should refer to huggingface for details. I would try to just put the right files in the right locations, or to modify this file:

def data_root():
if "INFRA_PROVIDER" in os.environ:
return Path("")
# Try to download from hugginface if it doesn't exist
path = Path(snapshot_download(repo_id="EvolutionaryScale/esm3-sm-open-v1"))
return path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants