deepspeedai / deepspeedai/DeepSpeed
[BUG] Step 3 with ZeRO=3 see error: RuntimeError: CUDA error: an illegal memory access was encountered
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Describe the bug
A clear and concise description of what the bug is. Please include which training step you are using and which model you are training.
Training Step: 3-RLHF
Training model: actor: facebook/opt-350m, critic: opt-350m(default)
Description:
RuntimeError: CUDA error: an illegal memory access was encountered
See this error when training on step 3 with ZeRO stage 3 running on 4 GPUs.
No error when running exact same script on 2 or 3 GPUs.
Log output
-------------------------------------------------------------------------------------
|E2E latency=6.57s |Gather latency=0.01s (0.19%) |Generate time=4.78s (72.69%) |Training time=0.94s (14.25%) |Others=0.86 (13.06%)|CurSamplesPerSec=2.43 |AvgSamplesPerSec=2.46
Traceback (most recent call last):
File "/home/cc/miniconda3/lib/python3.11/site-packages/deepspeed/runtime/hybrid_engine.py", line 253, in generate
generate_ret_vals = self._generate(*inputs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/cc/DeepSpeedExamples/applications/DeepSpeed-Chat/training/step3_rlhf_finetuning/main.py", line 694, in <module>
main()
File "/home/cc/DeepSpeedExamples/applications/DeepSpeed-Chat/training/step3_rlhf_finetuning/main.py", line 545, in main
out = trainer.generate_experience(batch_prompt['prompt'],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
AssertionError: {'id': 2, 'status': 'AVAILABLE', 'numel': 524288, 'ds_numel': 524288, 'shape': (512, 1024), 'ds_shape': (512, 1024), 'requires_grad': True, 'grad_shape': None, 'persist': False, 'active_sub_modules': {5}, 'ds_tensor.shape': torch.Size([131072])}
[E ProcessGroupNCCL.cpp:916] [Rank 3] NCCL watchdog thread terminated with exception: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
Exception raised from c10_cuda_check_implementation at ../c10/cuda/CUDAException.cpp:44 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x57 (0x7f06f7b0f617 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::string const&) + 0x64 (0x7f06f7aca98d in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x118 (0x7f06f7bcb128 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libc10_cuda.so)
frame #3: c10d::ProcessGroupNCCL::WorkNCCL::finishedGPUExecutionInternal() const + 0x80 (0x7f0683101250 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so)
frame #4: c10d::ProcessGroupNCCL::WorkNCCL::isCompleted() + 0x58 (0x7f0683105078 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so)
frame #5: c10d::ProcessGroupNCCL::workCleanupLoop() + 0x250 (0x7f068311b910 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so)
frame #6: c10d::ProcessGroupNCCL::ncclCommWatchdog() + 0x78 (0x7f068311bc18 in /home/cc/miniconda3/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so)
frame #7: <unknown function> + 0xdbbf4 (0x7f06c7cdbbf4 in /home/cc/miniconda3/bin/../lib/libstdc++.so.6)
frame #8: <unknown function> + 0x94b43 (0x7f0704094b43 in /lib/x86_64-linux-gnu/libc.so.6)
frame #9: <unknown function> + 0x126a00 (0x7f0704126a00 in /lib/x86_64-linux-gnu/libc.so.6)
link: https://drive.google.com/drive/folders/1LcCcwgH33DBYSF1FlXTgkZo2AFhwsyAf
To Reproduce
- Step 1 SFT model: use facebook/opt-350 model with default script in
opt/single_node/run_1.3b.sh - Step 3 RLHF: directly run the shell script similar to
opt/single_node/run_1.3b.shwith below difference:
ACTOR_MODEL_PATH="/home/cc/DeepSpeedExamples/applications/DeepSpeed-Chat/output/actor-models/1.3b/"
ZERO_STAGE=3
ACTOR_ZERO_STAGE=$ZERO_STAGE
CRITIC_ZERO_STAGE=$ZERO_STAGE
- Run on 2, 3, 4 GPUs (Tesla V100-SXM2-32GB)
- See above error when running with 4 GPUs only.
Expected behavior
Run successful
ds_report output
Please run ds_report to give us details about your setup.
[2024-01-12 05:48:11,882] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
runtime if needed. Op compatibility means that your system
meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
[WARNING] async_io requires the dev libaio .so object and headers but these were not found.
[WARNING] async_io: please install the libaio-dev package with apt
[WARNING] If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
async_io ............... [NO] ....... [NO]
fused_adam ............. [NO] ....... [OKAY]
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
cpu_lion ............... [NO] ....... [OKAY]
[WARNING] Please specify the CUTLASS repo directory as environment variable $CUTLASS_PATH
evoformer_attn ......... [NO] ....... [NO]
fused_lamb ............. [NO] ....... [OKAY]
fused_lion ............. [NO] ....... [OKAY]
inference_core_ops ..... [NO] ....... [OKAY]
cutlass_ops ............ [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
ragged_device_ops ...... [NO] ....... [OKAY]
ragged_ops ............. [NO] ....... [OKAY]
random_ltd ............. [NO] ....... [OKAY]
[WARNING] sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.1
[WARNING] using untested triton version (2.1.0), only 1.0.0 is known to be compatible
sparse_attn ............ [NO] ....... [NO]
spatial_inference ...... [NO] ....... [OKAY]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/home/cc/miniconda3/lib/python3.11/site-packages/torch']
torch version .................... 2.1.2+cu121
deepspeed install path ........... ['/home/cc/miniconda3/lib/python3.11/site-packages/deepspeed']
deepspeed info ................... 0.12.6, unknown, unknown
torch cuda version ............... 12.1
torch hip version ................ None
nvcc version ..................... 12.2
deepspeed wheel compiled w. ...... torch 0.0, cuda 0.0
shared memory (/dev/shm) size .... 62.67 GB
Screenshots
N/A
System info (please complete the following information):
- OS: Ubuntu 22.04.3 LTS
- GPU count and types: one machine with 4 x Tesla V100-SXM2-32GB
- DeepSpeed-Chat version:
commit 6c31d8ddee9e57f6202aeb4ee3c86f2fbd93d4c6 (HEAD -> master, origin/master, origin/HEAD)
Author: foin6 <61218792+foin6@users.noreply.github.com>
Date: Fri Jan 12 02:22:40 2024 +0800
- (if applicable) Hugging Face Transformers/Accelerate/etc. versions: Transformers: 4.36.2 | Accelerate: 0.26.1
- Python version: 3.11.5
- Any other relevant info about your setup: NVIDIA-SMI 535.86.10 | Driver Version: 535.86.10 | CUDA Version: 12.2
Docker context
N/A
Additional context
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing Step 3 RLHF with the configuration described in opt/single_node/run_1.3b.sh, using ZeRO stage 3 on 2, 3, and 4 V100 GPUs. Inspect the generate path in DeepSpeed runtime/hybrid_engine.py and the call from applications/DeepSpeed-Chat/training/step3_rlhf_finetuning/main.py. Done means the four-GPU run completes without the illegal memory access or assertion failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100