1.直接自动下载
但我的电脑要么卡住进度0,要么就报错网络连接不上
OSError: There was a specific connection error when trying to load gpt2:
Connection error, and we cannot find the requested files in the disk cache. Please try again or make sure your Internet connection is on.
2 用终端下载
自动下载
使用镜像
安装依赖
pip install -U huggingface_hub
设置环境
# Linux
export HF_ENDPOINT=https://hf-mirror.com
# Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"
下载模型到本地
huggingface-cli download --resume-download gpt2 --local-dir gpt2
大概会这样
有几个可能网络断断续续没下下来,自己核对一下
当然从镜像里面手动一个一个下载也是一样的,可能会慢(已尝试,非常慢)
因为是手动下载,所以要么把程序的调用路径改到保存路径下,要么把下载的内容储存到他正常自动下载的目录下,在我这里是
这样跟直接python下载下来一样的直接调用,不需要改路径了。