微信扫码
添加专属顾问
我要投稿
近日,通义千问团队震撼开源 Qwen1.5 系列首个千亿参数模型 Qwen1.5-110B-Chat。
千亿级大模型普通显卡是跑不了推理的,普通人一般也没办法本地运行千亿级大模型。
为了探索千亿级大模型到底需要计算资源,我用云计算资源部署了Qwen1.5-110B-Chat,看看部署它到底需要多少存储资源,并且测试在不量化、8bit量化、4bit量化下的显存消耗。
#模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('qwen/Qwen1.5-110B-Chat', cache_dir='path/to/local/dir')
下载后模型目录结构如下:
.
├── config.json
├── configuration.json
├── generation_config.json
├── LICENSE
├── merges.txt
├── model-00001-of-00062.safetensors
├── model-00002-of-00062.safetensors
├── model-00003-of-00062.safetensors
├── model-00004-of-00062.safetensors
├── model-00005-of-00062.safetensors
...
├── model-00062-of-00062.safetensors
├── model.safetensors.index.json
├── out.txt
├── README.md
├── tokenizer_config.json
├── tokenizer.json
└── vocab.json
0 directories, 73 files
模型Qwen1.5-110B-Chat共占用硬盘空间208G。
按照计算公式:模型显存占用(GB) = 大模型参数(B)*2
那么Qwen1.5-110B-Chat的显存占用量应该为220GB。
实际在部署过程中,没有考虑任何量化技术,占用显存215GB。
因此,如果你想完整部署Qwen1.5-110B-Chat,不考虑任何量化技术,需要3块80GB显存的显卡。
当然你可以玩量化,在 Transformers 中使用 LLM.int8() 只需提前安装pip install bitsandbytes即可,使用 LLM.int8() 方法量化transformer模型具体示例如下:
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
'qwen/Qwen1___5-110B-Chat',
device_map='auto',
load_in_8bit=True,
max_memory={
i: f'{int(torch.cuda.mem_get_info(i)[0]/1024**3)-2}GB'
for i in range(torch.cuda.device_count())
}
)
经测试,如果你采用8bit量化部署Qwen1.5-110B,需要113GB显存。
from transformers import BitsAndBytesConfig
import torch
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16
)
model_nf4 = AutoModelForCausalLM.from_pretrained('qwen/Qwen1___5-110B-Chat', quantization_config=nf4_config)
经测试,如果你采用4bit量化部署Qwen1.5-110B,需要62GB显存,预计1块80GB显存显卡即可部署。
简单问一个弱智吧的问题。
from modelscope import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
"/home/data/qwen/Qwen1___5-110B-Chat",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("/jydata/qwen/Qwen1___5-110B-Chat")
prompt = "树上有3只鸟,我用步枪打死一只,还有几只鸟?"
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-03-23
128K Star 的开源 AI 编程 Agent,把 Anthropic 逼到发律师函了
2026-03-23
字节跳动开源 DeerFlow 2.0:下一代超级 Agent 引擎,一键搞定复杂工作流!
2026-03-23
企业中职能部门打工人如何选小龙虾
2026-03-23
MiniMax开源技能包:让AI写代码从大学生变资深工程师
2026-03-22
OxyGent:构建高效能多智能体系统的协作框架
2026-03-22
Ollama绝赞适配World Monitor:无需API密钥的全球情报看板,金融地缘一手掌握!`
2026-03-22
重磅!VS Code 正式“改名”!绿色版 VS Code 更强!
2026-03-21
Hugging Face:AI 界的 GitHub 与开源协作的终极生态杠杆
2026-01-27
2026-01-30
2026-01-12
2026-01-29
2026-01-27
2026-01-28
2026-01-21
2025-12-23
2026-01-06
2026-01-26
2026-03-17
2026-03-13
2026-03-02
2026-02-05
2026-01-28
2026-01-26
2026-01-21
2026-01-21