Skip to content

Commit e1991ac

Browse files
xiangxu-googlekwang3939
authored andcommitted
Cache HF models in CI (#410)
Signed-off-by: Xiang Xu <xiangxu@google.com>
1 parent 1277324 commit e1991ac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.buildkite/scripts/run_in_docker.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ if [ -z "${MODEL_IMPL_TYPE:-}" ]; then
3636
MODEL_IMPL_TYPE=flax_nnx
3737
fi
3838

39+
# Try to cache HF models
40+
persist_cache_dir="/mnt/disks/persist/models"
41+
home_cache_dir="$HOME/models"
42+
43+
if ( mkdir -p "$persist_cache_dir" ); then
44+
LOCAL_HF_HOME="$persist_cache_dir"
45+
elif ( mkdir -p "$home_cache_dir" ); then
46+
LOCAL_HF_HOME="$home_cache_dir"
47+
else
48+
echo "Error: Failed to create either $persist_cache_dir or $home_cache_dir"
49+
exit 1
50+
fi
51+
DOCKER_HF_HOME="/tmp/hf_home"
52+
3953
# Prune older images on the host to save space.
4054
docker system prune -a -f --filter "until=3h"
4155

@@ -48,6 +62,8 @@ exec docker run \
4862
--net host \
4963
--shm-size=16G \
5064
--rm \
65+
-v "$LOCAL_HF_HOME":"$DOCKER_HF_HOME" \
66+
-e HF_HOME="$DOCKER_HF_HOME" \
5167
-e TPU_BACKEND_TYPE="$TPU_BACKEND_TYPE" \
5268
-e MODEL_IMPL_TYPE="$MODEL_IMPL_TYPE" \
5369
-e HF_TOKEN="$HF_TOKEN" \

0 commit comments

Comments
 (0)