lmdeploy icon indicating copy to clipboard operation
lmdeploy copied to clipboard

[Bug] [ascend] CLI conversation terminated abnormally

Open littlegy opened this issue 1 year ago • 2 comments

Checklist

  • [ ] 1. I have searched related issues but cannot get the expected help.
  • [ ] 2. The bug has not been fixed in the latest version.
  • [ ] 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

在昇腾设备A2上使用官方提供的镜像,在容器内通过命令启动模型,可以正常对话,但是结束对话会调度_cuda_clearCublasWorkspaces,昇腾环境中不存在

Reproduction

镜像:使用官方文档提供镜像 启动命令:lmdeploy chat Qwen3-0.6B --backend pytorch --device ascend --session-len 4096

Environment

docker run -e ASCEND_VISIBLE_DEVICES=0 --rm --name lmdeploy -t crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:910b-latest lmdeploy check_env
sys.platform: linux
Python: 3.10.5 (main, May  7 2025, 03:17:40) [GCC 9.4.0]
CUDA available: False
MUSA available: False
numpy_random_seed: 2147483648
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
PyTorch: 2.3.1
PyTorch compiling details: PyTorch built with:
  - GCC 10.2
  - C++ Version: 201703
  - Intel(R) MKL-DNN v3.3.6 (Git Hash 86e6af5974177e513fd3fee58425e1063e7f1361)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: NO AVX
  - Build settings: BLAS_INFO=open, BUILD_TYPE=Release, CXX_COMPILER=/opt/rh/devtoolset-10/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -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=open, TORCH_VERSION=2.3.1, USE_CUDA=OFF, USE_CUDNN=OFF, USE_CUSPARSELT=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF, 

TorchVision: 0.18.1
LMDeploy: 0.8.0+
transformers: 4.52.4
gradio: Not Found
fastapi: 0.115.12
pydantic: 2.11.6
triton: Not Found

Error traceback

/usr/local/python3.10.5/lib/python3.10/site-packages/torch_npu/contrib/transfer_to_npu.py:301: ImportWarning: 
    *************************************************************************************************************
    The torch.Tensor.cuda and torch.nn.Module.cuda are replaced with torch.Tensor.npu and torch.nn.Module.npu now..
    The torch.cuda.DoubleTensor is replaced with torch.npu.FloatTensor cause the double type is not supported now..
    The backend in torch.distributed.init_process_group set to hccl now..
    The torch.cuda.* and torch.cuda.amp.* are replaced with torch.npu.* and torch.npu.amp.* now..
    The device parameters have been replaced with npu in the function below:
    torch.logspace, torch.randint, torch.hann_window, torch.rand, torch.full_like, torch.ones_like, torch.rand_like, torch.randperm, torch.arange, torch.frombuffer, torch.normal, torch._empty_per_channel_affine_quantized, torch.empty_strided, torch.empty_like, torch.scalar_tensor, torch.tril_indices, torch.bartlett_window, torch.ones, torch.sparse_coo_tensor, torch.randn, torch.kaiser_window, torch.tensor, torch.triu_indices, torch.as_tensor, torch.zeros, torch.randint_like, torch.full, torch.eye, torch._sparse_csr_tensor_unsafe, torch.empty, torch._sparse_coo_tensor_unsafe, torch.blackman_window, torch.zeros_like, torch.range, torch.sparse_csr_tensor, torch.randn_like, torch.from_file, torch._cudnn_init_dropout_state, torch._empty_affine_quantized, torch.linspace, torch.hamming_window, torch.empty_quantized, torch._pin_memory, torch.autocast, torch.load, torch.Generator, torch.Tensor.new_empty, torch.Tensor.new_empty_strided, torch.Tensor.new_full, torch.Tensor.new_ones, torch.Tensor.new_tensor, torch.Tensor.new_zeros, torch.Tensor.to, torch.nn.Module.to, torch.nn.Module.to_empty
    *************************************************************************************************************
    
  warnings.warn(msg, ImportWarning)
/usr/local/python3.10.5/lib/python3.10/site-packages/torch_npu/contrib/transfer_to_npu.py:260: RuntimeWarning: torch.jit.script and torch.jit.script_method will be disabled by transfer_to_npu, which currently does not support them, if you need to enable them, please do not use transfer_to_npu.
  warnings.warn(msg, RuntimeWarning)
2025-08-22 03:18:10,729 - lmdeploy - WARNING - transformers.py:22 - LMDeploy requires transformers version: [4.33.0 ~ 4.51.0], but found version: 4.52.4
Loading weights from safetensors: 100%|███████████████████████████████████| 1/1 [00:00<00:00,  3.18it/s]
/opt/lmdeploy/lmdeploy/pytorch/backends/dlinfer/ascend/graph_runner.py:65: RuntimeWarning: 

************************************************************
  Graph mode is an experimental feature. We currently
  support both dense and Mixture of Experts (MoE) models
  with bf16 and fp16 data types.
  If graph mode does not function correctly with your model,
  please consider using eager mode as an alternative.
************************************************************


  warnings.warn(

double enter to end input >>> exit
Traceback (most recent call last):
  File "/opt/lmdeploy/lmdeploy/pytorch/chat.py", line 99, in run_chat
    asyncio.run(__chat_loop(model_path))
  File "/usr/local/python3.10.5/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/python3.10.5/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/local/python3.10.5/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/local/python3.10.5/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/local/python3.10.5/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/opt/lmdeploy/lmdeploy/pytorch/chat.py", line 91, in __chat_loop
    await __chat_step(prompt)
  File "/opt/lmdeploy/lmdeploy/pytorch/chat.py", line 78, in __chat_step
    exit(0)
  File "/usr/local/python3.10.5/lib/python3.10/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3.10.5/bin/lmdeploy", line 33, in <module>
    sys.exit(load_entry_point('lmdeploy', 'console_scripts', 'lmdeploy')())
  File "/opt/lmdeploy/lmdeploy/cli/entrypoint.py", line 39, in run
    args.run(args)
  File "/opt/lmdeploy/lmdeploy/cli/cli.py", line 244, in chat
    run_chat(args.model_path, engine_config, chat_template_config=chat_template_config)
  File "/opt/lmdeploy/lmdeploy/pytorch/chat.py", line 93, in run_chat
    with pipeline(
  File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 316, in __exit__
    self.close()
  File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 310, in close
    torch._C._cuda_clearCublasWorkspaces()
AttributeError: module 'torch._C' has no attribute '_cuda_clearCublasWorkspaces'
[ERROR] 2025-08-22-03:18:21 (PID:3450, Device:0, RankID:-1) ERR99999 UNKNOWN application exception
/usr/local/python3.10.5/lib/python3.10/tempfile.py:837: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/tmpnspl_imf'>

littlegy avatar Aug 22 '25 03:08 littlegy

我们重现一下

jinminxi104 avatar Aug 26 '25 07:08 jinminxi104

Image

I tested it and couldn't reproduce the error mentioned above.

tangzhiyi11 avatar Sep 28 '25 03:09 tangzhiyi11