AutoDL服务器huggingface模型下载到.cache了怎么办

强调一下,这个教程只是用来亡羊补牢的,可以通过先设置好 local_dir 和 cache_dir 避免。

1. huggingface的文件下载逻辑

首先我们先介绍一下huggingface的文件下载逻辑。

这里参考如何快速下载huggingface模型——全方法总结 - 知乎中的4.1节。

简而言之,local_dir里只有符号链接,真正的模型文件在.cache里。

2. 解决方法

2.1 方法一:修改符号链接

很容易想到把.cache里的文件移到数据盘,然后修改符号链接至新地址。

教程如下:

第一步,我们要知道local_dir中哪些文件是符号链接。

如上图所示,标了箭头的就是。

然后是怎么修改它。

看这个,重复的就不写了,不如自己看教程。

Python 修改符号链接(symlink)的方法|极客教程

2.2 方法二:官方api

 还有一种方法我没试,是官方文档里的。

使用snapshot_download重新“下载”一遍,指定参数 local_dir 和 local_dir_use_symlinks 取 false。

if you don’t want symlinks at all you can disable them (local_dir_use_symlinks=False). The cache directory will still be used to check wether the file is already cached or not. If already cached, the file is duplicated from the cache (i.e. saves bandwidth but increases disk usage). If the file is not already cached, it will be downloaded and moved directly to the local dir. This means that if you need to reuse it somewhere else later, it will be re-downloaded.

简而言之,它会把你.cache里的文件复制到 local_dir 里,具体结果如何就得看各位自己试了:),有问题可以放在评论区。

  • 11
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值