Search
🐹

[Errno 13] Permission denied: '/.cache’

===== Application Startup at 2025-06-02 13:34:58 ===== INFO:app:Loading Whisper model... Ignored error while writing commit hash to /.cache/huggingface/hub/models--Systran--faster-whisper-tiny/refs/main: [Errno 13] Permission denied: '/.cache'. WARNING:huggingface_hub._snapshot_download:Ignored error while writing commit hash to /.cache/huggingface/hub/models--Systran--faster-whisper-tiny/refs/main: [Errno 13] Permission denied: '/.cache'. ERROR:app:Failed to load model: [Errno 13] Permission denied: '/.cache' INFO: Started server process [1] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
Shell
복사
앱이 정상적으로 실행되었지만, 모델 로딩이 실패한 상태이다. 따라서 앱은 켜졌지만 제대로 작동하지 않는 상태라고 볼 수 있다.

원인

Hugging Face 모델(faster-whisper)을 다운로드하는 과정에서 /root/.cache 혹은 /.cache에 접근하려고 하는데, Docker 컨테이너 내에서 해당 디렉토리에 쓸 권한이 없기 때문이다.

해결 방법: 캐시 경로 변경

HUGGINGFACE_HUB_CACHE 환경변수를 설정하여 쓰기 가능한 디렉토리로 캐시 경로를 바꿔주면 되며, 예를 들어 /app/cache를 사용하도록 설정한다.

1. DockerFile에 추가

RUN mkdir -p /app/cache ENV HUGGINGFACE_HUB_CACHE=/app/cache
Docker
복사

2. Python (e.g., app.py) 코드에 추가

import os os.environ["HUGGINGFACE_HUB_CACHE"] = "/app/cache"
Python
복사