deepspeedai / deepspeedai/DeepSpeed

[BUG] RuntimeError: The specified pointer resides on host memory and is not registered with any CUDA device.

Open
#3,795 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug inference
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Describe the bug
I am using 4 A10 GPUs to do inference with facebook/opt-350m model. I am using TorchServe for inference.
TorchServe can dynamically batch incoming requests to do batch inference.

I am running into this error when processing batched requests. Issue doesn't happen all the time. As shown in the logs, four inferences with batch size=4 each worked as expected. Issue happens with the 5th request in this case.

To Reproduce
Steps to reproduce the behavior:

  1. I am not sure how I can repro this in a script. I have tried sending batched requests in a for loop. This works as expected.
    I can show how to do this in torchserve. It would require you to install it and run some commands there.
    Please let me know if you want me to do this.

Logs

2023-06-23T01:33:39,451 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Backend received inference at: 1687484019
2023-06-23T01:33:39,451 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Batch size is 4
2023-06-23T01:33:39,452 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Backend received inference at: 1687484019
2023-06-23T01:33:39,452 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Batch size is 4
2023-06-23T01:33:39,453 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Backend received inference at: 1687484019
2023-06-23T01:33:39,453 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Batch size is 4
2023-06-23T01:33:39,453 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Backend received inference at: 1687484019
2023-06-23T01:33:39,453 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Batch size is 4
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - Traceback (most recent call last):
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/home/ubuntu/anaconda3/envs/deepspeed/lib/python3.10/site-packages/ts/service.py", line 134, in predict
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     ret = self._entry_point(input_batch, self.context)
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/home/ubuntu/anaconda3/envs/deepspeed/lib/python3.10/site-packages/ts/torch_handler/base_handler.py", line 343, in handle
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     output = self.inference(data_preprocess)
2023-06-23T01:33:39,463 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/custom_handler.py", line 131, in inference
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     outputs = self.model.generate(**input_batch, **generate_kwargs)
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/utils/_contextlib.py", line 115, in decorate_context
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return func(*args, **kwargs)
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/transformers/generation/utils.py", line 1522, in generate
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return self.greedy_search(
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/transformers/generation/utils.py", line 2339, in greedy_search
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     outputs = self(
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/nn/modules/module.py", line 1501, in _call_impl
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return forward_call(*args, **kwargs)
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/transformers/models/opt/modeling_opt.py", line 945, in forward
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     outputs = self.model.decoder(
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/nn/modules/module.py", line 1501, in _call_impl
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return forward_call(*args, **kwargs)
2023-06-23T01:33:39,464 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/transformers/models/opt/modeling_opt.py", line 711, in forward
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     layer_outputs = decoder_layer(
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/nn/modules/module.py", line 1501, in _call_impl
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return forward_call(*args, **kwargs)
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/deepspeed/model_implementations/transformers/ds_transformer.py", line 147, in forward
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     self.attention(input,
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/nn/modules/module.py", line 1501, in _call_impl
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return forward_call(*args, **kwargs)
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/deepspeed/ops/transformer/inference/ds_attention.py", line 160, in forward
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     context_layer, key_layer, value_layer = self.compute_attention(qkv_out=qkv_out,
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/deepspeed/ops/transformer/inference/ds_attention.py", line 99, in compute_attention
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     attn_key_value = self.score_context_func(
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/torch/nn/modules/module.py", line 1501, in _call_impl
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     return forward_call(*args, **kwargs)
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -   File "/tmp/models/cca858804c534c48b477e2388642b420/deepspeed/ops/transformer/inference/op_binding/softmax_context.py", line 31, in forward
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG -     output = self.softmax_context_func(query_key_value, attn_mask, self.config.rotary_dim, self.config.rotate_half,
2023-06-23T01:33:39,465 [INFO ] W-29500-benchmark_1.0-stdout MODEL_LOG - RuntimeError: The specified pointer resides on host memory and is not registered with any CUDA device.

Expected behavior
A clear and concise description of what you expected to happen.

ds_report output
Please run ds_report to give us details about your setup.

--------------------------------------------------
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]
cpu_adagrad ............ [NO] ....... [OKAY]
cpu_adam ............... [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
random_ltd ............. [NO] ....... [OKAY]
 [WARNING]  sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.0
 [WARNING]  using untested triton version (2.0.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]
utils .................. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/home/ubuntu/anaconda3/envs/deepspeed/lib/python3.10/site-packages/torch']
torch version .................... 2.0.1+cu117
deepspeed install path ........... ['/home/ubuntu/anaconda3/envs/deepspeed/lib/python3.10/site-packages/deepspeed']
deepspeed info ................... 0.9.2, unknown, unknown
torch cuda version ............... 11.7
torch hip version ................ None
nvcc version ..................... 11.7
deepspeed wheel compiled w. ...... torch 2.0, cuda 11.7

Screenshots
If applicable, add screenshots to help explain your problem.

System info (please complete the following information):

  • OS: Ubuntu 20.04
  • GPU count and types : g5.12xlarge
  • (if applicable) what DeepSpeed-MII version are you using
  • (if applicable) Hugging Face Transformers/Accelerate/etc. versions HF: 4.30.1
  • Python version : 3.10
  • Any other relevant info about your setup

Docker context
Are you using a specific docker image that you can share?

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the traceback locations in deepspeed/ops/transformer/inference/op_binding/softmax_context.py and deepspeed/ops/transformer/inference/ds_attention.py, then run ds_report. Reproduce the intermittent failure with TorchServe batching, four A10 GPUs, and facebook/opt-350m; done means the host-memory pointer failure is isolated and a verified fix or minimal reproduction is available.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.