首页 > 其他分享 >zeRO-Offload代码实践

zeRO-Offload代码实践

时间:2023-03-23 23:22:47浏览次数:53  
标签:engine optimizer 代码 zero zeRO Offload model offload

https://mp.weixin.qq.com/s/VOgNPEcDhmhMuDdy_HL0BA

from deepspeed.ops.zero_offload import FP16ZeROOffloadEngine

# Initialize the ZeRO-Offload engine
zero_offload_engine = FP16ZeROOffloadEngine()

# Wrap the model with the ZeRO-Offload engine
model, _, _, _ = zero_offload_engine.initialize(model=model, optimizer=optimizer)

# Train the model
for batch in data:
    loss = model(batch)
    loss.backward()
    optimizer.step()
    optimizer.zero_grad()

标签:engine,optimizer,代码,zero,zeRO,Offload,model,offload
From: https://www.cnblogs.com/douzujun/p/17249896.html

相关文章