acoustic-van-30942
04/27/2023, 4:20 AMOutOfMemoryError: Container killed due to memory usage
Does Metaflow enforce a hard memory limit for ECS containers?
I'm using a p3.16xlarge and this is my resource config:
N_CPU = 32
N_GPU = 8
MEMORY = 250000victorious-lawyer-58417
04/27/2023, 4:43 AMacoustic-van-30942
04/27/2023, 4:47 AMvictorious-lawyer-58417
04/27/2023, 4:48 AMmemory=400000 . We can fix it accordinglyacoustic-van-30942
04/27/2023, 4:49 AMacoustic-van-30942
04/27/2023, 5:04 AMRuntimeError: ProcessGroupNCCL is only supported with GPUs, no GPUs found!
Usually, I add this environment variable - "NVIDIA_DRIVER_CAPABILITIES": "compute,utility", , but when I add that I have trouble doing a pip install for deepspeed and transformers , resulting in the below error:
assert cuda_home is not None, "CUDA_HOME does not exist, unable to compile CUDA op(s)victorious-lawyer-58417
04/27/2023, 5:39 AMvictorious-lawyer-58417
04/27/2023, 5:40 AMacoustic-van-30942
04/27/2023, 6:46 AMtorch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 3; 15.78 GiB total capacity; 14.85 GiB already allocated; 235.75 MiB free; 14.85 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
I might be getting this error because I set bf16 to false though. But interestingly, if I set to true, it complains that volta-100 is not compatible with bf16crooked-jordan-29960
04/27/2023, 2:13 PMcrooked-jordan-29960
04/27/2023, 2:21 PMbf16 is only for A100 GPUs as far as I'm aware.acoustic-van-30942
04/27/2023, 4:20 PMcrooked-jordan-29960
04/27/2023, 5:21 PMacoustic-van-30942
04/27/2023, 6:45 PMtorch.cuda.OutOfMemoryErrorvictorious-lawyer-58417
04/27/2023, 7:00 PM--num_gpus=3 - currently you have 16 or 32GB VRAM / GPU which might not be enough
we ran our tests on an A100 that had 80GB VRAM / GPUvictorious-lawyer-58417
04/27/2023, 7:00 PMacoustic-van-30942
04/27/2023, 7:04 PMp3dn.24xlarge šcrooked-jordan-29960
04/27/2023, 7:06 PMp3dn.24xlarge, which can be a crapshoot to access right now so sadflat-television-23413
04/27/2023, 7:15 PMp3.8xlarge p3.16xlarge.
I think there are also some deepspeed options that might help here, although I am not an expert in the framework. In ds_config,json, there is this zero optimizer section, where you can tell deepspeed to move parameters (zero stage 3 only) and optimizer state to CPU or NVMe memory like this:
"zero_optimization": {
"stage": 3,
...
"offload_param": {
"device": "[cpu|nvme]",
"nvme_path": "/local_nvme",
"pin_memory": [true|false],
"buffer_count": 5,
"buffer_size": 1e8,
"max_in_cpu": 1e9
},
"offload_optimizer": {
"device": "[cpu|nvme]",
"nvme_path": "/local_nvme",
"pin_memory": [true|false],
"buffer_count": 4,
"fast_init": false
},
...
}acoustic-van-30942
04/27/2023, 7:30 PMcrooked-jordan-29960
04/27/2023, 7:31 PMp3.16xlarge could hold the model to do predictions, but the gradient syncing required for training was where memory issue came into playacoustic-van-30942
04/27/2023, 7:32 PMcrooked-jordan-29960
04/27/2023, 7:32 PMacoustic-van-30942
05/01/2023, 7:44 PMcrooked-jordan-29960
05/01/2023, 7:45 PMacoustic-van-30942
05/01/2023, 7:48 PMacoustic-van-30942
05/01/2023, 7:55 PMcrooked-jordan-29960
05/01/2023, 8:03 PM"zero_optimization" like:
"offload_param": {
"device": "cpu",
"pin_memory": true
}
Some other parameters we can tune to reduce max GPU memory requirements:
stage3_max_live_parameters
stage3_max_reuse_distancecrooked-jordan-29960
05/01/2023, 8:04 PMacoustic-van-30942
05/01/2023, 8:05 PMacoustic-van-30942
05/01/2023, 8:12 PMmax_live_parameters and max_reuse_distancecrooked-jordan-29960
05/01/2023, 8:17 PMacoustic-van-30942
05/01/2023, 8:19 PMmax_length a tadcrooked-jordan-29960
05/01/2023, 8:20 PMacoustic-van-30942
05/02/2023, 1:09 AMmax_length to 512 and used padding. That seems to have unblocked me and gotten me past that bump in the road. Not sure if that will impact accuracy significantly, but seems to be consistent with some of the tricks being used here: https://docs.ray.io/en/master/ray-air/examples/gptj_deepspeed_fine_tuning.htmlcrooked-jordan-29960
05/02/2023, 1:33 AMacoustic-van-30942
05/02/2023, 1:33 AMcrooked-jordan-29960
05/02/2023, 1:43 AMacoustic-van-30942
05/02/2023, 1:44 AMacoustic-van-30942
05/02/2023, 3:04 AMRuntimeError("Could not find response key token IDs")
I believe the RESPONSE KEY token is missing from the input data due to the truncating I did above ?crooked-jordan-29960
05/02/2023, 4:59 AMtrainer.py file with the response key. It is fixed now so think it may work if you can either pull change or do the minimal edit changing RESPONSE_KEY to RESPONSE_KEY_NL in the response_token_ids = self.tokenizer.encode(RESPONSE_KEY_NL) line.acoustic-van-30942
05/02/2023, 5:15 AM### RESPONSE KEY\nacoustic-van-30942
05/02/2023, 3:38 PMcrooked-jordan-29960
05/02/2023, 3:45 PMacoustic-van-30942
05/02/2023, 3:56 PMvictorious-lawyer-58417
05/02/2023, 4:20 PM