facebookresearch/fairscale

Question in offload.py: Moving activation to CPU does NOT reduce GPU memory.

開放

#948 建立於 2022年3月4日

 (14 則留言) (0 個反應) (0 位負責人)Python (297 個分叉)auto 404
bughelp wantedoffload_modeltriaged

倉庫指標

星標
 (3,411 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

I use my cuda_active_bytes function to measure the GPU memory before and after the code line below. I find moving activation to CPU does NOT reduce GPU memory. https://github.com/facebookresearch/fairscale/blob/9f347f373e32ee5cad11a40b70b8e28a74b5e2d4/fairscale/experimental/nn/offload.py#L524

def cuda_active_bytes():
    torch.cuda.synchronize()
    stats = torch.cuda.memory_stats()
    current_active_byte =  stats['active_bytes.all.current']
    return current_active_byte

So actually all the activations generated by forward is still in GPU memory? If so, I think the code line above is redundant.

貢獻者指南