AUVDiDo commited on
Commit
345d83e
·
verified ·
1 Parent(s): 0107558

Delete run.py

Browse files
Files changed (1) hide show
  1. run.py +0 -43
run.py DELETED
@@ -1,43 +0,0 @@
1
- import transformers
2
- import torch
3
- from modelscope import snapshot_download
4
-
5
- model_id = snapshot_download("LLM-Research/Llama-3.3-70B-Instruct")
6
-
7
- pipeline = transformers.pipeline(
8
- "text-generation",
9
- model=model_id,
10
- model_kwargs={"torch_dtype": torch.bfloat16},
11
- device_map="auto",
12
- )
13
-
14
- messages = [
15
- {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
16
- {"role": "user", "content": "Who are you?"},
17
- ]
18
-
19
-
20
- with torch.profiler.profile(
21
- activities=[
22
- torch.profiler.ProfilerActivity.CPU,
23
- # torch.profiler.ProfilerActivity.CUDA, # 捕捉 aten function 的调用仅开 CPU 就够了
24
- ],
25
- #record_shapes=True,
26
- #with_stack=True,
27
- ) as p:
28
- outputs = pipeline(
29
- messages,
30
- max_new_tokens=256,
31
- )
32
- print(outputs[0]["generated_text"][-1])
33
-
34
- table_str = p.key_averages().table(
35
- sort_by="count",
36
- row_limit=-1,
37
- max_src_column_width=100,
38
- max_name_column_width=100, # 限制列宽
39
- )
40
- with open("Llama-3.3-70B-Instruct.txt", 'wt') as f:
41
- f.write(table_str)
42
-
43
-