当前位置:网站首页>无缝支持Hugging Face社区,Colossal-AI低成本轻松加速大模型
无缝支持Hugging Face社区,Colossal-AI低成本轻松加速大模型
2022-07-13 19:41:00 【潞晨科技】


文本到图像生成样例“一个被猫绊倒的希腊人雕像”(左侧两列为Imagen,右侧两列为DALL·E 2)


低成本加速大模型OPT
OPT模型
添加配置文件
tensor_placement_policy决定了我们异构训练的策略,这个参数可以为 cuda、 cpu以及 auto。各个策略有不同的优点: cuda: 将全部模型参数都放置于GPU上,适合不offload时仍然能进行训练的传统场景;
cpu则会将模型参数都放置在CPU内存中,仅在GPU显存中保留当前参与计算的权重,适合超大模型的训练;
auto则会根据实时的内存信息,自动决定保留在GPU显存中的参数量,这样能最大化利用GPU显存,同时减少CPU-GPU之间的数据传输。
auto策略,由Colossal-AI自动化地实时动态选择最佳异构策略,最大化计算效率。from colossalai.zero.shard_utils import TensorShardStrategyzero = dict(model_config=dict(shard_strategy=TensorShardStrategy(), tensor_placement_policy="auto"), optimizer_config=dict(gpu_margin_mem_ratio=0.8))运行启动
colossalai.launch_from_torch(config='./configs/colossalai_zero.py')ZeroInitContext下初始化即可。在例子里,我们使用Hugging Face提供的OPTForCausalLM模型以及预训练权重,在Wikitext数据集上进行微调。 with ZeroInitContext(target_device=torch.cuda.current_device(), shard_strategy=shard_strategy, shard_param=True): model = OPTForCausalLM.from_pretrained( 'facebook/opt-1.3b' config=config )colossalai.initialize,便可将配置文件里定义的异构内存功能统一注入到训练引擎中,即可启动相应功能。 engine, train_dataloader, eval_dataloader, lr_scheduler = colossalai.initialize(model=model, optimizer=optimizer, criterion=criterion, train_dataloader=train_dataloader, test_dataloader=eval_dataloader, lr_scheduler=lr_scheduler)优势显著

-nprocs 8即可实现! 背后秘诀


便捷高效并行扩展
parallel = dict( pipeline=2, tensor=dict(mode='2.5d', depth = 1, size=4))
传送门
招聘
参考文献:
边栏推荐
- Uniapp applet and H5 compressed image upload
- Selected multiple choice questions of spark final exam
- odoo的assets详述
- gpu服务器注意事项
- Qt+vs project imports relevant DLLs under the release/debug folder (very practical)
- Odoo multi company
- dtcloud的消息机制(三)
- 2. JVM object creation and memory allocation
- Summary of Lin Ziyu spark Scala programming
- [application rapide] le contenu de l'accord utilisateur et de la politique de confidentialité de l'application rapide peut être sauté plusieurs fois. Cliquez sur retour pour retourner à la page précéd
猜你喜欢

Vscode input! No prompt, unable to automatically complete the solution (latest)

TIOBE - 2022年7月编程语言排行

使用百度开发者工具 4.0 搭建专属的小程序 IDE

Harmony应用上架报错“请使用发布版本的API开发应用申请上架”的解决方案

基于PyQt的分组工具

Introduction to odoo cli (1)

Uniapp applet and H5 compressed image upload

jmm内存模型及volatile实现原理

字符串库函数和内存操作库函数详解及模拟实现

Kanban view of dtcloud qWeb practice
随机推荐
云原生 DevOps 现状调研问卷征集:KodeRover 联合 OSCHINA 推出
dtcloud的消息机制(三)
解释初始化列表
Dotnet Nuget 设置代理解决源不可访问的问题
基于模型的强化学习综述
Laravel 用户认证中 attempt方法
dtcloud Qweb实战之看板视图
scala快速入门
建立自己的网站(21)
I opened the permission of datastutio and automatically generated an SQL task that has been executing, which indicates that the permission allocation has not been completed
Famous pipeline principle and detailed explanation (very practical)
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Odoo owl explanation
Input get focus
031 Log4j日志框架
Write an OpenGL renderer from scratch -- infrastructure construction
Introduction to odoo cli (1)
解决WINDOS文件夹需要管理员权限无法删除,高级安全设置无法更改所者权限,点击变灰色
【付费推广】常见问题合集,基础推广操作FAQ 1
Common mailbox access protocols