Repository navigation
Replies: 5 comments
|
It seems that problem is that $HF_DATASETS_CACHE cannot be populated offline. If I load the dataset prior to removing network access it does not fail. |
|
|
|
The fix is setting Here's the corrected workflow: export HF_HOME=/shared/huggingface
export HF_HUB_CACHE=/shared/huggingface/hub # this is where hf download saves
export HF_DATASETS_OFFLINE=1 # key: tells datasets to not hit the network
# Download first (while online)
huggingface-cli download TIGER-Lab/MMLU-Pro --repo-type dataset
# Then offline, use load_dataset normally:
python -c "from datasets import load_dataset; ds = load_dataset('TIGER-Lab/MMLU-Pro')"The critical env var is import os
os.environ["HF_DATASETS_OFFLINE"] = "1"
from datasets import load_dataset
ds = load_dataset("TIGER-Lab/MMLU-Pro")Docs reference: [https://huggingface.co/docs/datasets/en/cache#offline-mode](https://huggingface.co/docs/datasets/en/cache) Verify the files are actually therels $HF_HUB_CACHE/datasets--TIGER-Lab--MMLU-Pro/ Should show snapshots/ folderAlso try passing the local path explicitly as fallback:ds = load_dataset("parquet", data_files={"train": "/shared/huggingface/hub/datasets--TIGER-Lab--MMLU-Pro/snapshots//data/.parquet"}) |
|
hf download populates the Hub cache, but datasets.load_dataset() still appears to resolve the dataset script/metadata using the repo ID. In offline mode, that lookup can fail before the Hub cache is consulted. One approach you could try is to “warm” the datasets cache while online: from datasets import load_dataset This should prepare the dataset under HF_DATASETS_CACHE. Then, after switching to: export HF_HUB_OFFLINE=1 try the same call again: load_dataset("TIGER-Lab/MMLU-Pro") If I understand the caching behavior correctly, this should allow the dataset to resolve from the local datasets cache without requiring network access. If you only run: hf download TIGER-Lab/MMLU-Pro --repo-type dataset you’ll have the repository files in the Hub cache, but not necessarily the dataset builder state required by datasets.load_dataset() for offline use. As a fallback, using the local path returned by hf download should also work. It would definitely be nice if repo IDs could resolve directly from the Hub cache in offline mode. |
Why This HappensWhen you use Calling Solution 1: Use
|
Uh oh!
There was an error while loading. Please reload this page.
I'd like to download datasets from HF and then run completely disconnected. I can do this by using file paths, but it's not ideal. I'd really like to use the repo_id and have it resolved locally when offline. Is there any way to do this? My failing workflow looks like:
All reactions