出现"No space left on device"可能由存储路径配置或缓存文件积累导致。

[rank0]: return _hf_hub_download_to_cache_dir( [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank0]: File "/root/miniconda3/envs/FlexWorld/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1011, in _hf_hub_download_to_cache_dir [rank0]: _download_to_tmp_and_move( [rank0]: File "/root/miniconda3/envs/FlexWorld/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1545, in _download_to_tmp_and_move [rank0]: http_get( [rank0]: File "/root/miniconda3/envs/FlexWorld/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 457, in http_get [rank0]: temp_file.write(chunk) [rank0]: OSError: [Errno 28] No space left on device

​删除HuggingFace缓存路径
下载过程涉及huggingface_hub模块,其默认缓存路径为~/.cache/huggingface。执行以下命令清理:

rm -rf ~/.cache/huggingface/hub/*

但是往往我们不想要把下好的模型从缓存中删除,于是我们可以使用存储路径重定向(适用于大文件下载)的方法,基于符号链接方式将HuggingFace缓存重定向到AutoDL数据盘的具体操作步骤。这样就算数据盘不够,也可以扩容数据盘。

步骤:

在数据盘创建专用缓存目录:

mkdir -p /root/autodl-tmp/huggingface_cache
  • 参数说明:
    • -p:递归创建多级目录
    • 路径规范:建议保持huggingface_cache命名一致

建立符号链接 

删除原缓存目录(如已存在):

rm -rf ~/.cache/huggingface  # 强制删除原目录

 创建软链接:

ln -sf /root/autodl-tmp/huggingface_cache ~/.cache/huggingface

验证

测试缓存写入:

python -c "from huggingface_hub import hf_hub_download; hf_hub_download('bert-base-uncased', 'config.json')"

验证存储位置:

du -sh /root/autodl-tmp/huggingface_cache  # 查看下载文件是否存入数据盘

解决 !

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐