model = AutoModelForCausalLM.from_pretrained(“baichuan-inc/baichuan-7B”, device_map=”auto”, trust_remote_code=True)
英文解释:
1 | By passing device_map="auto", we tell 🤗 Accelerate to determine automatically where to put each layer of the model depending on the available resources: |
中文解释:
通过传递device_map=”auto”,它告诉机器决定怎样加载模型,基于已有的资源将模型的每一层放在合适的位置:
- 第一,会使用最大的gpu空间资源
- 如果仍然需要空间,那么会存储一部分权重到cpu
- 如果RAM内存不足,那么会存储一部分权重到硬盘上作为内存映射
不会的记录下来。
