DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

[BUG] zero3 offload_optimizer error when set ratio

Open ShaoxunZeng opened this issue 2 years ago • 2 comments

When I enable zero3 offload_optimizer, and set ratio to 0.5, error occurs when initiate optimizer

RuntimeError: expected input to be on cuda

config:

{
  "train_batch_size": 8,
  "gradient_accumulation_steps": 1,
  "optimizer": {
    "type": "Adam",
    "params": {
      "lr": 0.00015
    }
  },
  "zero_optimization": {
    "stage": 3,
    "offload_param": {
      "device": "cpu"
    },
    "offload_optimizer": {
      "device": "nvme",
      "nvme_path": "/mnt/nvme",
      "ratio": 0.5
    }
  }
}

ShaoxunZeng avatar Dec 26 '23 11:12 ShaoxunZeng

same issue

Trangle avatar Jan 26 '24 01:01 Trangle

Hi thx @ShaoxunZeng & @Trangle for raising this issue. the config for offload_optimizer in your setup is incorrect.

device should be cpu, not nvme, thus no nvme_path needed. also please set pin_memory: True. In short correct offload_optimizer config look like this:

         "offload_optimizer": {
            "device": "cpu",
            "pin_memory": True,
            "ratio": 0.5
        }

When I enable zero3 offload_optimizer, and set ratio to 0.5, error occurs when initiate optimizer

RuntimeError: expected input to be on cuda

config:

{
  "train_batch_size": 8,
  "gradient_accumulation_steps": 1,
  "optimizer": {
    "type": "Adam",
    "params": {
      "lr": 0.00015
    }
  },
  "zero_optimization": {
    "stage": 3,
    "offload_param": {
      "device": "cpu"
    },
    "offload_optimizer": {
      "device": "nvme",
      "nvme_path": "/mnt/nvme",
      "ratio": 0.5
    }
  }
}

GuanhuaWang avatar Jan 26 '24 03:01 GuanhuaWang