[huggingface] cache directory 변경

황준하·2025년 2월 10일

cache directory를 바꿀 사용자의 home에서 .bashrc 파일 수정

vi .bashrc

.bashrc 파일 내 환경 변수 추가

변경할 경로로 적어주기

  1. HF_HOME: main cache directory
  2. HF_DATASETS_CACHE: huggingface_hub의 dataset이 저장되는 곳
export HF_HOME="/home/user/10TB/.cache/huggingface"
export HF_DATASETS_CACHE="/home/user/10TB/.cache/huggingface/datasets"

수정 완료 후 .bashrc 실행

  • 주피터가 켜져있었다면 끄고 다시 시작해야지 적용됨
source .bashrc




심볼릭 링크 걸기

이렇게 하는게 더 간단한 것 같다.

본인의 home/user/.cache 경로로 들어가서 아래와 같이 원하는 경로로 심볼릭 링크를 걸어주면 된다.

ln -s <연결하고자 하는 원본 파일/폴더의 경로> <새로 생성하는 링크의 경로>

ln -s /data/cb-user/.cache/huggingface/

기존에 사용하던 폴더가 있다면

mv /huggingface/* /mnt/data/hf_cache/
rm -rf huggingface
ln -s /data/.cache/huggingface /home/egg2018037024/.cache/huggingface

출처

https://huggingface.co/docs/datasets/cache

0개의 댓글