DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

[BUG] Deepspeed MultiGpu inference not working with `Llama-2-13b-hf`

Open Rishabhg71 opened this issue 2 years ago • 0 comments

Describe the bug

I was trying to run an inference with DeepSpeed on the Llama model, but when I ran deepspeed --num_gpus 4 script.py, the process terminated automatically after loading the checkpoint shards, without providing any additional information. Also, when running nvidia-smi, it appears that the model wasn’t even loaded, and no process was created, or it was created for a minimal amount of time.

[2023-12-26 13:12:37,547] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2023-12-26 13:12:40,313] [WARNING] [runner.py:202:fetch_hostfile] Unable to find hostfile, will proceed with training with local resources only.
[2023-12-26 13:12:40,352] [INFO] [runner.py:571:main] cmd = /opt/conda/bin/python3.10 -u -m deepspeed.launcher.launch --world_info=eyJsb2NhbGhvc3QiOiBbMCwgMSwgMiwgM119 --master_addr=127.0.0.1 --master_port=29500 --enable_each_rank_log=None script.py
[2023-12-26 13:12:42,637] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2023-12-26 13:12:43,352] [INFO] [launch.py:145:main] WORLD INFO DICT: {'localhost': [0, 1, 2, 3]}
[2023-12-26 13:12:43,352] [INFO] [launch.py:151:main] nnodes=1, num_local_procs=4, node_rank=0
[2023-12-26 13:12:43,352] [INFO] [launch.py:162:main] global_rank_mapping=defaultdict(<class 'list'>, {'localhost': [0, 1, 2, 3]})
[2023-12-26 13:12:43,352] [INFO] [launch.py:163:main] dist_world_size=4
[2023-12-26 13:12:43,352] [INFO] [launch.py:165:main] Setting CUDA_VISIBLE_DEVICES=0,1,2,3
[2023-12-26 13:12:46,236] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2023-12-26 13:12:46,236] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2023-12-26 13:12:46,253] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2023-12-26 13:12:46,254] [INFO] [real_accelerator.py:161:get_accelerator] Setting ds_accelerator to cuda (auto detect)
Loading checkpoint shards:  67%|█████████████████████████████████████▎                  | 2/3 [02:31<01:15, 75.65s/it][2023-12-26 13:15:58,389] [INFO] [launch.py:315:sigkill_handler] Killing subprocess 45345
[2023-12-26 13:15:58,511] [INFO] [launch.py:315:sigkill_handler] Killing subprocess 45346
[2023-12-26 13:16:00,882] [INFO] [launch.py:315:sigkill_handler] Killing subprocess 45347
[2023-12-26 13:16:03,251] [INFO] [launch.py:315:sigkill_handler] Killing subprocess 45348
[2023-12-26 13:16:05,660] [ERROR] [launch.py:321:sigkill_handler] ['/opt/conda/bin/python3.10', '-u', 'script.py', '--local_rank=3'] exits with return code = -9
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.104.12             Driver Version: 535.104.12   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  Tesla T4                       On  | 00000000:00:1B.0 Off |                    0 |
| N/A   22C    P8               9W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   1  Tesla T4                       On  | 00000000:00:1C.0 Off |                    0 |
| N/A   23C    P8               9W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   2  Tesla T4                       On  | 00000000:00:1D.0 Off |                    0 |
| N/A   23C    P8               9W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   3  Tesla T4                       On  | 00000000:00:1E.0 Off |                    0 |
| N/A   22C    P8               8W /  70W |      2MiB / 15360MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

To Reproduce

  • Run this script using deepspeed --num_gpus 4 script.py

from transformers import LlamaForCausalLM, AutoTokenizer, AutoModel

import deepspeed
import torch

# Specify the model name
model_name = "meta-llama/Llama-2-13b-hf"

# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Load the model
model = LlamaForCausalLM.from_pretrained(model_name, token="hf_<token>")
# model = AutoModel.from_pretrained(model_name, token="hf_<token>")



# Initialize the DeepSpeed-Inference engine
ds_engine = deepspeed.init_inference(model,
                                 mp_size=2,
                                 dtype=torch.half)
model = ds_engine.module
output = model('Input String')

This original script is taken from https://www.deepspeed.ai/tutorials/inference-tutorial/#initializing-for-inference

Expected behavior A successful inference output

ds_report output

[2023-12-26 15:09:06,338] [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 ............... ['/opt/conda/lib/python3.10/site-packages/torch']
torch version .................... 2.1.2+cu121
deepspeed install path ........... ['/opt/conda/lib/python3.10/site-packages/deepspeed']
deepspeed info ................... 0.12.6, unknown, unknown
torch cuda version ............... 12.1
torch hip version ................ None
nvcc version ..................... 12.1
deepspeed wheel compiled w. ...... torch 0.0, cuda 0.0
shared memory (/dev/shm) size .... 93.30 GB

System info (please complete the following information):

  • Pytorch Version: 2.1.2+cu121
  • Cuda version: 12.2
  • OS version: Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.1.0 (Ubuntu 20.04) 20231205
  • Instance Type: g4dn.12xlarge (4 GPUS) specs
  • Transformers: 4.36.2
  • Python: 3.10

Rishabhg71 avatar Dec 26 '23 15:12 Rishabhg71