[工具环境] pip&git lfs下载命令

关键词: pip, git lfs

pip从git下载指定的提交版本

伴随着大模型的火热发展,PEFT和transformers也是更新频繁,常会看到requirements中安装的软件包来自github中的某个commit hash,比如requirements中:

peft @ git+https://github.com/huggingface/peft.git@e536616888d51b453ed354a6f1e243fecb02ea08

如果存在安装失败,比如网络等问题,可以手动单独对这个包进行安装,有以下两种方法:

  • 手动pip安装,指定git commit hash
pip install git+https://github.com/huggingface/peft@e536616888d51b453ed354a6f1e243fecb02ea08
  • 下载github上对应的库,并切换到对应的commit hash,再手动安装
git clone https://github.com/huggingface/peft.git
cd peft
git checkout e536616888d51b453ed354a6f1e243fecb02ea08
# 查看当前版本对应的commmit hash
git rev-parse --short HEAD

# 安装该commit hash下的版本
pip install .

git lfs下载大文件

目前大部分开源大模型都在huggingface models中存放,可以通过git lfs进行下载。
通过git-lfs --version查看是否安装,如未安装可参考git-lfs进行安装。

  • 从huggingface models下载模型文件,如
git clone https://huggingface.co/THUDM/chatglm-6b

由于模型文件比较大,可以先下载指针文件,然后再下载lfs文件,这样可以实时显示下载速度和进度。

git clone  https://huggingface.co/THUDM/chatglm-6b
cd chatglm-6b
git lfs pull

具体使用参考https://zzz.buzz/zh/2016/04/19/the-guide-to-git-lfs/

----------END----------

猜你喜欢

转载自blog.csdn.net/iling5/article/details/130892564