GLM-4.5模型下载:HuggingFace全系列
2026-02-04 05:26:10作者:苗圣禹Peter
还在为下载超大规模语言模型而烦恼?面对3550亿参数的GLM-4.5系列模型,不知道如何高效下载和部署?本文为你提供最完整的GLM-4.5模型下载指南,从基础概念到实战操作,一文解决所有下载难题!
🎯 读完本文你能得到
- ✅ GLM-4.5全系列模型详细对比与选择指南
- ✅ 多种下载方式详解(HuggingFace、ModelScope、Git LFS)
- ✅ 完整的环境配置与依赖安装步骤
- ✅ 模型验证与完整性检查方法
- ✅ 不同硬件配置下的部署建议
- ✅ 常见问题排查与解决方案
📊 GLM-4.5系列模型全景图
GLM-4.5系列包含多个版本,满足不同场景需求:
| 模型名称 | 总参数 | 活跃参数 | 精度 | 适用场景 | 下载大小 |
|---|---|---|---|---|---|
| GLM-4.5 | 355B | 32B | BF16 | 高性能推理 | ~358GB |
| GLM-4.5-Air | 106B | 12B | BF16 | 平衡性能 | ~107GB |
| GLM-4.5-FP8 | 355B | 32B | FP8 | 高效推理 | ~179GB |
| GLM-4.5-Air-FP8 | 106B | 12B | FP8 | 轻量部署 | ~54GB |
| GLM-4.5-Base | 355B | 32B | BF16 | 基础模型 | ~358GB |
| GLM-4.5-Air-Base | 106B | 12B | BF16 | 轻量基础 | ~107GB |
graph TD
A[GLM-4.5系列] --> B[标准版 355B-A32B]
A --> C[轻量版 Air 106B-A12B]
B --> D[BF16精度]
B --> E[FP8精度]
B --> F[Base基础版]
C --> G[BF16精度]
C --> H[FP8精度]
C --> I[Base基础版]
D --> J[完整功能]
E --> K[高效推理]
F --> L[无指令调优]
G --> M[平衡性能]
H --> N[极致轻量]
I --> O[基础能力]
🛠️ 环境准备与依赖安装
系统要求
# 检查系统环境
nvidia-smi # 确认GPU驱动
nvcc --version # 确认CUDA版本
python --version # Python 3.8+
安装核心依赖
# 创建虚拟环境
python -m venv glm45-env
source glm45-env/bin/activate
# 安装基础依赖
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# 安装transformers和相关库
pip install transformers>=4.54.0
pip install accelerate
pip install sentencepiece
pip install protobuf
# 可选:安装推理框架
pip install vllm # 高性能推理
pip install sglang # 流式推理
📥 多种下载方式详解
方式一:HuggingFace官方下载
使用huggingface-hub库
from huggingface_hub import snapshot_download
import os
# 设置模型路径
model_id = "zai-org/GLM-4.5"
# 下载完整模型
snapshot_download(
repo_id=model_id,
local_dir="./glm-4-5-model",
local_dir_use_symlinks=False,
resume_download=True,
allow_patterns=["*.json", "*.safetensors", "*.bin", "*.txt"]
)
print("模型下载完成!")
使用git命令(推荐大文件)
# 安装git-lfs
sudo apt-get install git-lfs
git lfs install
# 克隆仓库(包含大文件)
git clone https://huggingface.co/zai-org/GLM-4.5
# 或者只下载模型文件
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/zai-org/GLM-4.5
cd GLM-4.5
git lfs pull
方式二:ModelScope下载(国内优化)
from modelscope import snapshot_download
# 使用ModelScope下载(网络优化)
model_dir = snapshot_download(
'ZhipuAI/GLM-4.5',
cache_dir='./model_cache',
revision='master'
)
print(f"模型下载到: {model_dir}")
方式三:直接HTTP下载
对于网络环境特殊的用户,可以使用wget或curl直接下载:
# 获取下载链接列表
python -c "
from huggingface_hub import HfApi
api = HfApi()
files = api.list_repo_files('zai-org/GLM-4.5')
for file in files:
if file.endswith('.safetensors') or file.endswith('.json'):
print(f'https://huggingface.co/zai-org/GLM-4.5/resolve/main/{file}')
"
# 使用aria2多线程下载(推荐)
aria2c -x 16 -s 16 -i download_list.txt
🔍 模型验证与完整性检查
检查文件完整性
import os
import json
from safetensors import safe_open
def check_model_integrity(model_path):
"""检查模型文件完整性"""
# 检查必要文件是否存在
required_files = [
'config.json',
'generation_config.json',
'tokenizer_config.json',
'tokenizer.json',
'model.safetensors.index.json'
]
missing_files = []
for file in required_files:
if not os.path.exists(os.path.join(model_path, file)):
missing_files.append(file)
if missing_files:
print(f"缺失文件: {missing_files}")
return False
# 检查safetensors文件数量
with open(os.path.join(model_path, 'model.safetensors.index.json'), 'r') as f:
index_data = json.load(f)
expected_files = len(set(index_data['weight_map'].values()))
actual_files = len([f for f in os.listdir(model_path) if f.startswith('model-') and f.endswith('.safetensors')])
if actual_files != expected_files:
print(f"模型分片文件不完整: 期望 {expected_files} 个, 实际 {actual_files} 个")
return False
print("模型文件完整性检查通过!")
return True
# 执行检查
check_model_integrity('./glm-4-5-model')
验证模型加载
from transformers import AutoModel, AutoTokenizer
def test_model_loading(model_path):
"""测试模型是否能正常加载"""
try:
# 加载tokenizer
tokenizer = AutoTokenizer.from_pretrained(
model_path,
trust_remote_code=True
)
# 尝试加载模型(使用部分权重)
model = AutoModel.from_pretrained(
model_path,
trust_remote_code=True,
device_map="auto",
load_in_8bit=True, # 8bit加载节省内存
torch_dtype=torch.float16
)
print("模型加载成功!")
return True
except Exception as e:
print(f"模型加载失败: {e}")
return False
test_model_loading('./glm-4-5-model')
⚙️ 不同硬件配置建议
高端配置(8×H100/H200)
# GLM-4.5 BF16版本
vllm serve zai-org/GLM-4.5 \
--tensor-parallel-size 8 \
--tool-call-parser glm45 \
--reasoning-parser glm45 \
--enable-auto-tool-choice \
--served-model-name glm-4.5
中等配置(4×H100)
# GLM-4.5-Air BF16版本
vllm serve zai-org/GLM-4.5-Air \
--tensor-parallel-size 4 \
--tool-call-parser glm45 \
--reasoning-parser glm45 \
--enable-auto-tool-choice \
--served-model-name glm-4.5-air
入门配置(2×H100)
# GLM-4.5-Air FP8版本
vllm serve zai-org/GLM-4.5-Air-FP8 \
--tensor-parallel-size 2 \
--tool-call-parser glm45 \
--reasoning-parser glm45 \
--enable-auto-tool-choice \
--served-model-name glm-4.5-air-fp8
📋 下载优化技巧
1. 使用下载工具
# 使用多线程下载工具
git clone https://huggingface.co/zai-org/GLM-4.5
# 使用axel多连接下载
axel -n 10 https://huggingface.co/zai-org/GLM-4-5/resolve/main/model-00001-of-00093.safetensors
2. 断点续传配置
# 在代码中启用断点续传
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="zai-org/GLM-4.5",
resume_download=True,
local_dir="./glm-4-5-model",
max_workers=4 # 多线程下载
)
3. 选择性下载
# 只下载需要的精度版本
snapshot_download(
repo_id="zai-org/GLM-4.5-Air-FP8", # 选择轻量FP8版本
local_dir="./glm-4-5-air-fp8",
ignore_patterns=["*.bin", "*.h5"] # 忽略不必要的文件
)
🚀 快速开始示例
最小化部署示例
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# 加载模型和tokenizer
model_path = "./glm-4-5-air-fp8" # 使用轻量FP8版本
tokenizer = AutoTokenizer.from_pretrained(
model_path,
trust_remote_code=True
)
model = AutoModelForCausalLM.from_pretrained(
model_path,
trust_remote_code=True,
torch_dtype=torch.float16,
device_map="auto"
)
# 简单推理测试
input_text = "你好,请介绍一下GLM-4.5模型的特点"
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_length=100)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("模型响应:", result)
🔧 常见问题与解决方案
问题1:下载中断或网络错误
解决方案:
# 设置重试机制
export HF_HUB_ENABLE_HF_TRANSFER=1
export HF_HUB_NUM_RETRIES=10
export HF_HUB_RETRY_DELAY=5
# 使用国内镜像
export HF_ENDPOINT=https://hf-mirror.com
问题2:磁盘空间不足
解决方案:
# 清理缓存
rm -rf ~/.cache/huggingface/hub
# 使用符号链接
ln -s /path/to/large/disk/.cache ~/.cache/huggingface
问题3:内存不足无法加载
解决方案:
# 使用8bit或4bit量化
from transformers import BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(
load_in_8bit=True,
llm_int8_threshold=6.0
)
model = AutoModelForCausalLM.from_pretrained(
model_path,
quantization_config=quantization_config,
device_map="auto"
)
📈 性能优化建议
推理优化配置
# config.yaml
model_name: glm-4-5-air-fp8
tensor_parallel_size: 2
speculative_num_steps: 3
speculative_eagle_topk: 1
speculative_num_draft_tokens: 4
mem_fraction_static: 0.7
enable_auto_tool_choice: true
内存优化策略
# 梯度检查点
model.gradient_checkpointing_enable()
# 激活重计算
model.config.use_cache = False
# 使用Flash Attention
model.config.use_flash_attention_2 = True
🎯 总结与选择建议
根据你的需求选择合适的版本:
- 研究实验 → GLM-4.5-Base (完整能力)
- 生产部署 → GLM-4.5-Air-FP8 (高效推理)
- 资源受限 → GLM-4.5-Air (平衡性能)
- 极致性能 → GLM-4.5 (顶级效果)
下载决策流程图
flowchart TD
A[开始下载GLM-4.5] --> B{硬件配置如何?}
B -->|8+H100/H200| C[选择 GLM-4.5 BF16]
B -->|4+H100| D[选择 GLM-4.5-Air BF16]
B -->|2+H100| E[选择 GLM-4.5-Air FP8]
C --> F{网络环境如何?}
D --> F
E --> F
F -->|国际网络| G[使用 HuggingFace 官方]
F -->|国内网络| H[使用 ModelScope 加速]
G --> I[下载完成]
H --> I
I --> J[验证模型完整性]
J --> K[部署推理服务]
通过本文的详细指南,你应该能够顺利完成GLM-4.5系列模型的下载、验证和部署。如果在过程中遇到任何问题,欢迎在评论区留言讨论!
下一步行动:
- 根据硬件条件选择合适的模型版本
- 配置下载环境并开始下载
- 验证模型完整性
- 部署测试推理服务
祝您下载顺利,享受GLM-4.5带来的强大AI能力! 🚀
登录后查看全文
热门项目推荐
相关项目推荐
Kimi-K2.5Kimi K2.5 是一款开源的原生多模态智能体模型,它在 Kimi-K2-Base 的基础上,通过对约 15 万亿混合视觉和文本 tokens 进行持续预训练构建而成。该模型将视觉与语言理解、高级智能体能力、即时模式与思考模式,以及对话式与智能体范式无缝融合。Python00- QQwen3-Coder-Next2026年2月4日,正式发布的Qwen3-Coder-Next,一款专为编码智能体和本地开发场景设计的开源语言模型。Python00
xw-cli实现国产算力大模型零门槛部署,一键跑通 Qwen、GLM-4.7、Minimax-2.1、DeepSeek-OCR 等模型Go06
PaddleOCR-VL-1.5PaddleOCR-VL-1.5 是 PaddleOCR-VL 的新一代进阶模型,在 OmniDocBench v1.5 上实现了 94.5% 的全新 state-of-the-art 准确率。 为了严格评估模型在真实物理畸变下的鲁棒性——包括扫描伪影、倾斜、扭曲、屏幕拍摄和光照变化——我们提出了 Real5-OmniDocBench 基准测试集。实验结果表明,该增强模型在新构建的基准测试集上达到了 SOTA 性能。此外,我们通过整合印章识别和文本检测识别(text spotting)任务扩展了模型的能力,同时保持 0.9B 的超紧凑 VLM 规模,具备高效率特性。Python00
KuiklyUI基于KMP技术的高性能、全平台开发框架,具备统一代码库、极致易用性和动态灵活性。 Provide a high-performance, full-platform development framework with unified codebase, ultimate ease of use, and dynamic flexibility. 注意:本仓库为Github仓库镜像,PR或Issue请移步至Github发起,感谢支持!Kotlin08
VLOOKVLOOK™ 是优雅好用的 Typora/Markdown 主题包和增强插件。 VLOOK™ is an elegant and practical THEME PACKAGE × ENHANCEMENT PLUGIN for Typora/Markdown.Less00
项目优选
收起
deepin linux kernel
C
27
11
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
532
3.74 K
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
336
178
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
886
596
Ascend Extension for PyTorch
Python
340
403
暂无简介
Dart
771
191
Nop Platform 2.0是基于可逆计算理论实现的采用面向语言编程范式的新一代低代码开发平台,包含基于全新原理从零开始研发的GraphQL引擎、ORM引擎、工作流引擎、报表引擎、规则引擎、批处理引引擎等完整设计。nop-entropy是它的后端部分,采用java语言实现,可选择集成Spring框架或者Quarkus框架。中小企业可以免费商用
Java
12
1
openJiuwen agent-studio提供零码、低码可视化开发和工作流编排,模型、知识库、插件等各资源管理能力
TSX
986
247
本仓将收集和展示高质量的仓颉示例代码,欢迎大家投稿,让全世界看到您的妙趣设计,也让更多人通过您的编码理解和喜爱仓颉语言。
Cangjie
416
4.21 K
React Native鸿蒙化仓库
JavaScript
303
355