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

How to do inference without connecting to HuggingFace? #35

Open
ForestsKing opened this issue Mar 31, 2024 · 3 comments
Open

How to do inference without connecting to HuggingFace? #35

ForestsKing opened this issue Mar 31, 2024 · 3 comments
Labels
FAQ Frequently asked question

Comments

@ForestsKing
Copy link

The connection between my server and Hugging Face is not very smooth. I have downloaded the model weights. I would like to know if it is possible to close the connection to Hugging Face before calling Chronos, it often takes a lot of time and may fail. Thanks!

@abdulfatir
Copy link
Contributor

abdulfatir commented Mar 31, 2024

@ForestsKing typically, using a HF model prefix should not have a significant overhead. However, if you're facing issues with your connection, you might try downloading the model first and loading from a local path. Here's how to do it:

  • Download the model. You can do this in one of the following ways:
    • Clone the HF repo using git lfs as described here.
    • OR If you have used the model once, it should already be in your cache. HF models are saved in ~/.cache/huggingface/hub/models--<model-name>/snapshots/<commit-hash>/. Here's an example path from my machine ~/.cache/huggingface/hub/models--amazon--chronos-t5-small/snapshots/6cb0a414b8bc7ed3cfdcb7edac48a9778dd175f8/. You can copy this directory to another more accesible directory.
  • Once you have the model in a local path (let's say ./checkpoints/chronos-t5-small/), you can load it as follows:
import torch
from chronos import ChronosPipeline

pipeline = ChronosPipeline.from_pretrained(
    "./checkpoints/chronos-t5-small",
    device_map="cuda",
    torch_dtype=torch.bfloat16,
)

@ForestsKing
Copy link
Author

Thank!

@lostella lostella changed the title Close the connection to Hugging Face before inference How to do inference without connecting to Hugging Face Mar 31, 2024
@lostella lostella added the FAQ Frequently asked question label Mar 31, 2024
@lostella
Copy link
Contributor

Leaving open as FAQ

@lostella lostella reopened this Mar 31, 2024
@lostella lostella changed the title How to do inference without connecting to Hugging Face How to do inference without connecting to Hugging Face? Mar 31, 2024
@lostella lostella changed the title How to do inference without connecting to Hugging Face? How to do inference without connecting to HuggingFace? May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FAQ Frequently asked question
Projects
None yet
Development

No branches or pull requests

3 participants