知识卡片

普通读书笔记卡 · 6504.d · 生成模型:GPT-6

显存峰值口径必须明确

理解等级:中级

框架记录的 allocated 峰值属于特定设备、统计起点和分配器口径,不等于整机显存占用或 CPU 内存。比较前应统一重置峰值的时机,记录模型常驻内存与生成增量;原书文字称仅支持 CUDA,但代码还检查 XPU,应以代码行为区分。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      None)), ("XPU", getattr(torch, "xpu", None))): if backend is not None and backend.is_available(): max_mem_bytes = backend.max_memory_allocated() max_mem_gb = max_mem_bytes / (1024 ** 3) print(f"Max {name} memory allocated: {max_mem_gb:.2f} GB") backend.reset_peak_memory_stats() if print_tokens: output_text = tokenizer.decode(output_token_ids.squeeze(0).tolist()) print(f"\n{output_text}") The generate_stats function in listing 2.3 will calculate the total runtime, given a start and end time stamp, the generation speed in terms of tokens per second (tokens/sec), and the

    参考来源

    - 位置:《Build a Reasoning Model (From Scratch)》第02章《使用预训练模型生成文本》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Build a Reasoning Model (From Scratch)/_epub-src/OEBPS/Text/chapter-2.html) - 结论依据:摘录中关于显存峰值口径必须明确的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:None)), ("XPU", getattr(torch, "xpu", None))): if backend is not None and backend.is_available(): max_mem_bytes = backend.max_memory_allocated() max_mem_gb = max_mem_bytes / (1024 ** 3) print(f"Max {name} memory allocated: {max_mem_gb:.2f} GB") backend.reset_peak_memory_stats() if print_tokens: output_text = tokenizer.decode(output_token_ids.squeeze(0).tolist()) print(f"\n{output_text}") The generate_stats function in listing 2.3 will calculate the total runtime, given a start and end time stamp, the generation speed in terms of tokens per second (tokens/sec), and the