您的位置:首页 > 健康 > 美食 > 大型小程序软件开发_产品规划_域名查询ip爱站网_百度网站排名怎么提高

大型小程序软件开发_产品规划_域名查询ip爱站网_百度网站排名怎么提高

2025/2/23 21:09:30 来源:https://blog.csdn.net/qq_45193872/article/details/145697547  浏览:    关键词:大型小程序软件开发_产品规划_域名查询ip爱站网_百度网站排名怎么提高
大型小程序软件开发_产品规划_域名查询ip爱站网_百度网站排名怎么提高

问题描述:

在Ubuntu/centos系统中由于在大多数情况下无法科学上网从而无法登录huggingface录入access token下载模型,
常规理论操作如下

# 1. 安装 huggingface_hub (如果尚未安装)
pip install huggingface_hub# 2. 登录 Hugging Face
huggingface-cli login# 3. 安装 Git LFS (如果尚未安装)
sudo apt-get update
sudo apt-get install git-lfs
git lfs install# 4. 克隆模型仓库
git clone https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat# 5. 下载模型文件
cd deepseek-llm-7b-chat
git lfs pull

由于无法科学上网报错如下
在这里插入图片描述


问题确认:

ping不通huggingface:

ping huggingface.co

可以ping通百度:

ping baidu.com

在这里插入图片描述


解决方案:

由于无法通过 huggingface-cli login 登录,并且无法直接 git clone Hugging Face 上的模型,可以通过设置 HF_ENDPOINT 环境变量来使用镜像网站下载模型。

1. 设置 HF_ENDPOINT 环境变量:

在终端中设置 HF_ENDPOINT 环境变量,指向 Hugging Face 镜像站点。

export HF_ENDPOINT=https://hf-mirror.com

这告诉 huggingface_hub 库使用 https://hf-mirror.com 作为 Hugging Face Hub 的替代端点。

2. 使用 huggingface_hub 库下载模型:

由于无法使用 git clone 命令,需要使用 huggingface_hub 库中的 snapshot_download 函数来下载模型。

首先,需要创建一个 Python 脚本(例如 download_model.py),并在其中使用 snapshot_download 函数:

from huggingface_hub import snapshot_downloadmodel_id = "deepseek-ai/deepseek-llm-7b-chat"  # 模型 ID
local_dir = "./deepseek-llm-7b-chat"  # 本地保存目录 (可选)
local_dir_use_symlinks = False # 是否使用符号链接 (可选)try:snapshot_download(repo_id=model_id,local_dir=local_dir,local_dir_use_symlinks=local_dir_use_symlinks,cache_dir="./.cache" # 设置缓存目录 (可选))print(f"模型 {model_id} 成功下载到 {local_dir}")
except Exception as e:print(f"下载模型时出错: {e}")print("请检查你的网络连接和 HF_ENDPOINT 环境变量。")print("如果问题仍然存在,请尝试使用其他镜像站点或代理服务器。")

注意:

  • 请将 model_id 替换为你想要下载的deepseek模型的实际 ID。
  • 根据需要修改 local_dirlocal_dir_use_symlinks 参数。

3. 运行 Python 脚本:

在终端中运行 Python 脚本:

python download_model.py

结果展示:

成功下载模型,可进行后续部署操作:

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com