mirror of
https://github.com/deepseek-ai/DeepSeek-V2.git
synced 2026-11-05 00:47:23 +00:00
[GH-ISSUE #37] 服务器部署问题 #34
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-V2#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @airsxue on GitHub (May 17, 2024).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-V2/issues/37
请问我用这个demo在linux运行v2需要安装哪些环境?谢谢
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
model_name = "deepseek-ai/DeepSeek-V2-Chat"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
max_memoryshould be set based on your devicesmax_memory = {i: "75GB" for i in range(8)}
device_mapcannot be set toautomodel = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="sequential", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation="eager")
model.generation_config = GenerationConfig.from_pretrained(model_name)
model.generation_config.pad_token_id = model.generation_config.eos_token_id
messages = [
{"role": "user", "content": "Write a piece of quicksort code in C++"}
]
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
print(result)
@haichuan1221 commented on GitHub (May 20, 2024):
同问
@stack-heap-overflow commented on GitHub (May 27, 2024):
需要安装的python库包括:
torch,transformers,accelerate。相关库不同版本的兼容性并没有详细测过,这里可以给一个我测试用的环境供参考,不一定需要严格符合:
torch == 2.1.0transformers == 4.39.3accelerate == 0.29.3