InternLM / InternLM/lmdeploy

[Bug] CUDA error with Qwen/Qwen2-VL-7B-Instruct

Open
#3,101 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
748
Avg merge
6d 2h
Merged PRs (30d)
54

Description

### Checklist

- [x] 1. I have searched related issues but cannot get the expected help.
- [x] 2. The bug has not been fixed in the latest version.
- [x] 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.

### Describe the bug

Qwen/Qwen2-VL-7B-Instruct is not able to serve any requests due to a CUDA error.

### Reproduction

```
lmdeploy serve api_server Qwen/Qwen2-VL-7B-Instruct
```

### Environment

```Shell
sys.platform: linux
Python: 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA H100 80GB HBM3
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.4, V12.4.131
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.4.0+cu121
PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v3.4.2 (Git Hash 1137e04ec0b5251ca2b4400a4fd3c667ce843d67)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX512
- CUDA Runtime 12.1
- NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
- CuDNN 90.1 (built against CUDA 12.4)
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.1, CUDNN_VERSION=9.1.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDL
E -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=pedantic -Wno
-error=old-style-cast -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=2.4.0, USE_CUDA=ON, USE_CUDNN=ON, USE_CUSPARSELT=1, USE_EXCEPTION_PTR=1, USE_G
FLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF,

TorchVision: 0.19.0+cu121
LMDeploy: 0.7.0.post2+
transformers: 4.47.0
gradio: Not Found
fastapi: 0.115.6
pydantic: 2.10.3
triton: 3.0.0
NVIDIA Topology:
GPU0 NIC0 NIC1 NIC2 NIC3 NIC4 NIC5 NIC6 NIC7 NIC8 NIC9 NIC10 NIC11 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE PIX NODE 1,3,5,7,9,11 1 N/A
NIC0 SYS X PIX PIX NODE NODE NODE SYS SYS SYS SYS SYS SYS
NIC1 SYS PIX X PIX NODE NODE NODE SYS SYS SYS SYS SYS SYS
NIC2 SYS PIX PIX X NODE NODE NODE SYS SYS SYS SYS SYS SYS
NIC3 SYS NODE NODE NODE X NODE NODE SYS SYS SYS SYS SYS SYS
NIC4 SYS NODE NODE NODE NODE X NODE SYS SYS SYS SYS SYS SYS
NIC5 SYS NODE NODE NODE NODE NODE X SYS SYS SYS SYS SYS SYS
NIC6 NODE SYS SYS SYS SYS SYS SYS X PIX PIX NODE NODE NODE
NIC7 NODE SYS SYS SYS SYS SYS SYS PIX X PIX NODE NODE NODE
NIC8 NODE SYS SYS SYS SYS SYS SYS PIX PIX X NODE NODE NODE
NIC9 NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE X NODE NODE
NIC10 PIX SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE X NODE
NIC11 NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE X

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks

NIC Legend:

NIC0: mlx5_0
NIC1: mlx5_1
NIC2: mlx5_2
NIC3: mlx5_3
NIC4: mlx5_4
NIC5: mlx5_5
NIC6: mlx5_6
NIC7: mlx5_7
NIC8: mlx5_8
NIC9: mlx5_9
NIC10: mlx5_10
NIC11: mlx5_11

pip list installed | grep lmdeploy
lmdeploy 0.7.0.post2
```

### Error traceback

```Shell
Traceback (most recent call last):
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/engine.py", line 899, in __task_callback
task.result()
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/engine.py", line 857, in _async_loop_background
await self._async_step_background(
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/engine.py", line 727, in _async_step_background
output = await self._async_model_forward(inputs,
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/utils.py", line 234, in __tmp
return (await func(*args, **kwargs))
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/engine.py", line 625, in _async_model_forward
ret = await __forward(inputs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/engine.py", line 602, in __forward
return await self.model_agent.async_forward(inputs, swap_in_map=swap_in_map, swap_out_map=swap_out_map)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 256, in async_forward
output = self._forward_impl(inputs, swap_in_map=swap_in_map, swap_out_map=swap_out_map)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 239, in _forward_impl
output = model_forward(
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 151, in model_forward
output = model(**input_dict)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/backends/cuda/graph_runner.py", line 141, in __call__
return self.model(**kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/models/qwen2_vl.py", line 669, in forward
hidden_states = self.model(
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/models/qwen2_vl.py", line 287, in forward
cos, sin = _apply_mrope_selection(hidden_states, mrope_position_ids, self.mrope_section, position_ids,
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/models/qwen2_vl.py", line 26, in _apply_mrope_selection
cos, sin = rotary_emb_func(hidden_states, _mrope_position_ids)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/backends/default/rotary_embedding.py", line 59, in forward
return _rotary_embedding_fwd(position_ids,
File "/home/murali/Venvs/lmdeploy/lib/python3.10/site-packages/lmdeploy/pytorch/backends/default/rotary_embedding.py", line 30, in _rotary_embedding_fwd
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemmStridedBatched( handle, opa, opb, m, n, k, &alpha, a, lda, stridea, b, ldb, strideb, &beta, c, ldc, stridec, num_batches)`
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.