910b2上推理Cosyvoice2上推理一直报错The stream is not in the current context.
收藏回复举报
910b2上推理Cosyvoice2上推理一直报错The stream is not in the current context.
t('forum.solved') 已解决
发表于2025-09-19 17:13:51
0 查看

显卡为910b2

环境为autodl租用的节点

驱动版本:25.2.0

CANN: 8.2.RC1(8.1.rc1也测试过)

mindietorch                    2.0rc1+torch2.1.0.abi0

pytorch-lightning              2.5.5

torch                          2.3.1

torch-npu                      2.3.1.post6

torchaudio                     2.3.1

torchmetrics                   1.8.2

torchvision                    0.16.0

msit 信息

aclruntime                     0.0.2

ais-bench                      0.0.2

msit                           8.1.0

msit-analyze                   8.1.0

msit-benchmark                 8.1.0

msit-compare                   8.1.0

msit-convert                   8.1.0

msit-llm                       8.1.0

msit-profile                   8.1.0

msit-surgeon                   8.1.0

msit-tensor-view               8.1.0

报错信息如下:

/usr/local/lib64/python3.11/site-packages/torch/cuda/__init__.py:56: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.

  import pynvml  # type: ignore[import]

/usr/local/lib64/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:294: 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.set_default_device, 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.Tensor.pin_memory, torch.nn.Module.to, torch.nn.Module.to_empty

    *************************************************************************************************************

    

  warnings.warn(msg, ImportWarning)

/usr/local/lib64/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:249: 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)

/usr/local/lib64/python3.11/site-packages/torch_npu/dynamo/torchair/__init__.py:8: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

  import pkg_resources

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

  declare_namespace(pkg)

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('zope')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

  declare_namespace(pkg)

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

  declare_namespace(pkg)

2025-09-19 16:57:23,255 - modelscope - INFO - PyTorch version 2.3.1 Found.

2025-09-19 16:57:23,256 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer

2025-09-19 16:57:23,323 - modelscope - INFO - Loading done! Current index file version is 1.15.0, with md5 e7a5d9cd5907e72c833bfdfc0c4d2849 and a total number of 980 components indexed

failed to import ttsfrd, use WeTextProcessing instead

/usr/local/lib/python3.11/site-packages/lightning/fabric/__init__.py:41: Deprecated call to `pkg_resources.declare_namespace('lightning.fabric')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:2350: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('lightning')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

  declare_namespace(parent)

/usr/local/lib64/python3.11/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: '/usr/local/lib64/python3.11/site-packages/torchvision/image.so: undefined symbol: _ZN3c1017RegisterOperatorsD1Ev'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?

  warn(

/usr/local/lib/python3.11/site-packages/lightning/pytorch/__init__.py:37: Deprecated call to `pkg_resources.declare_namespace('lightning.pytorch')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:2350: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('lightning')`.

Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

  declare_namespace(parent)

/usr/local/lib/python3.11/site-packages/diffusers/models/lora.py:393: FutureWarning: `LoRACompatibleLinear` is deprecated and will be removed in version 1.0.0. Use of `LoRACompatibleLinear` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`.

  deprecate("LoRACompatibleLinear", "1.0.0", deprecation_message)

[INFO] input frame rate=25

/usr/local/lib/python3.11/site-packages/librosa/core/intervals.py:15: DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.

  with resources.path("librosa.core", "intervals.msgpack") as imsgpack:

Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.

Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.

/usr/local/lib64/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:65: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'CPUExecutionProvider'

  warnings.warn(

2025-09-19 16:57:45,962 WETEXT INFO building fst for zh_normalizer ...

[INFO] building fst for zh_normalizer ...

2025-09-19 16:58:35,700 WETEXT INFO done

[INFO] done

2025-09-19 16:58:35,701 WETEXT INFO fst path: /usr/local/lib/python3.11/site-packages/tn/zh_tn_tagger.fst

[INFO] fst path: /usr/local/lib/python3.11/site-packages/tn/zh_tn_tagger.fst

2025-09-19 16:58:35,701 WETEXT INFO           /usr/local/lib/python3.11/site-packages/tn/zh_tn_verbalizer.fst

[INFO]           /usr/local/lib/python3.11/site-packages/tn/zh_tn_verbalizer.fst

2025-09-19 16:58:35,710 WETEXT INFO found existing fst: /usr/local/lib/python3.11/site-packages/tn/en_tn_tagger.fst

[INFO] found existing fst: /usr/local/lib/python3.11/site-packages/tn/en_tn_tagger.fst

2025-09-19 16:58:35,710 WETEXT INFO                     /usr/local/lib/python3.11/site-packages/tn/en_tn_verbalizer.fst

[INFO]                     /usr/local/lib/python3.11/site-packages/tn/en_tn_verbalizer.fst

2025-09-19 16:58:35,710 WETEXT INFO skip building fst for en_normalizer ...

[INFO] skip building fst for en_normalizer ...

[WARN] acl repeat initialize

[INFO] acl init success

[INFO] open device 0 success

[INFO] get current context

[INFO] load model CosyVoice2-0.5B/flow_linux_aarch64.om success

[INFO] create model description success

[INFO] create new context

[INFO] load model CosyVoice2-0.5B/flow_static.om success

[INFO] create model description success

[INFO] create new context

[INFO] load model CosyVoice2-0.5B/speech_linux_aarch64.om success

[INFO] create model description success

Removing weight norm...

warm up start

  0%|                                                                                                                                                                                                                                         | 0/1 [00:00<?, ?it/s][INFO] synthesis text 收到好友从远方寄来的生日礼物,那份意外的惊喜和深深的祝福,让我心中充满了甜蜜的快乐,笑容如花儿般绽放。

  0%|                                                                                                                                                                                                                                         | 0/1 [00:00<?, ?it/s]

Traceback (most recent call last):

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/infer.py", line 118, in <module>

    no_stream_input_inference(args, cosyvoice, prompt_txt)

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/infer.py", line 26, in no_stream_input_inference

    for _ in enumerate(cosyvoice.inference_sft(prompt_txt[0], '中文女', stream=args.stream_out)):

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/cosyvoice/cli/cosyvoice.py", line 75, in inference_sft

    for model_output in self.model.tts(**model_input, stream=stream, speed=speed):

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/cosyvoice/cli/model.py", line 380, in tts

    for i in self.llm.inference(text=text.to(self.device),

  File "/usr/local/lib64/python3.11/site-packages/torch/utils/_contextlib.py", line 35, in generator_context

    response = gen.send(None)

               ^^^^^^^^^^^^^^

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/cosyvoice/llm/llm.py", line 338, in inference

    y_pred, cache = self.llm.forward_one_step(lm_input,

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/cosyvoice/llm/llm.py", line 234, in forward_one_step

    outs = self.model(

           ^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl

    return self._call_impl(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl

    return forward_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/transformers/src/transformers/models/qwen2/modeling_qwen2.py", line 846, in forward

    outputs, logits = self.model(

                      ^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl

    return self._call_impl(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl

    return forward_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/root/autodl-tmp/workspace/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/CosyVoice2/CosyVoice/transformers/src/transformers/models/qwen2/modeling_qwen2.py", line 476, in forward

    return self.cached_first_prefill(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch_npu/dynamo/torchair/inference/_cache_compiler.py", line 551, in __call__

    return self._compiled_model(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch_npu/dynamo/torchair/inference/_cache_compiler.py", line 476, in __call__

    return self.compiled_func(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 451, in _fn

    return fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 921, in catch_errors

    return callback(frame, cache_entry, hooks, frame_state, skip=1)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 400, in _convert_frame_assert

    return _compile(

           ^^^^^^^^^

  File "/usr/lib64/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 703, in _compile

    raise InternalTorchDynamoError(str(e)).with_traceback(

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 676, in _compile

    guarded_code = compile_inner(code, one_graph, hooks, transform)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/utils.py", line 262, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 535, in compile_inner

    out_code = transform_code_object(code, transform)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/bytecode_transformation.py", line 1036, in transform_code_object

    transformations(instructions, code_options)

  File "/usr/local/lib64/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 160, in _fn

    cuda_rng_state = torch.cuda.get_rng_state()

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib64/python3.11/site-packages/torch_npu/npu/random.py", line 32, in get_rng_state

    return default_generator.get_state()

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

torch._dynamo.exc.InternalTorchDynamoError: currentStreamCaptureStatusMayInitCtx:build/CMakeFiles/torch_npu.dir/compiler_depend.ts:77 NPU function error: c10_npu::acl::AclmdlRICaptureGetInfo(s.stream(false), &is_capturing, &model_ri), error code is 107003

[ERROR] 2025-09-19-16:59:23 (PID:513493, Device:0, RankID:-1) ERR00100 PTA call acl api failed

[Error]: The stream is not in the current context.

        Check whether the context where the stream is located is the same as the current context.

EE9999: Inner Error!

EE9999: [PID: 513493] 2025-09-19-16:59:23.868.857 stream is not in current ctx, stream_id=2.[FUNC:StreamGetCaptureInfo][FILE:api_impl.cc][LINE:7889]

        TraceBack (most recent call last):

       rtStreamGetCaptureInfo execute failed, reason=[stream not in current context][FUNC:FuncErrorReason][FILE:error_message_manage.cc][LINE:53]

You can suppress this exception and fall back to eager by setting:

    import torch._dynamo

    torch._dynamo.config.suppress_errors = True

[W compiler_depend.ts:234] Warning: NPU warning, error code is 107003[Error]: 

[Error]: The stream is not in the current context.

        Check whether the context where the stream is located is the same as the current context.

EE9999: Inner Error!

EE9999: [PID: 513493] 2025-09-19-16:59:23.887.164 Stream destroy failed, stream is not in current ctx, stream_id=2.[FUNC:StreamDestroy][FILE:api_impl.cc][LINE:1378]

        TraceBack (most recent call last):

       rtStreamDestroyForce execute failed, reason=[stream not in current context][FUNC:FuncErrorReason][FILE:error_message_manage.cc][LINE:53]

       destroy stream force failed, runtime result = 107003[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:161]

 (function operator())

[INFO] unload model success, model Id is 2147483649

[INFO] unload model success, model Id is 2147483648

[INFO] unload model success, model Id is 2

[WARN] acl repeat destroy

文档上说要源码安装msit,但是按照源码安装方式安装之后问题依旧

我要发帖子