Skip to content

基于昇腾npu部署本模型时报错及运行时报错 #54

Description

@wujian99

System Info / 系統信息

硬件环境:昇腾910B3
问题一:安装依赖包时报错如下,requirements_npu.txt中torch==2.3.1+cpu没有这个包,其中torchaudio等类似

python -m pip install -r requirements_npu.txt --no-build-isolation

Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu/
Collecting numpy==1.26.4 (from -r requirements_npu.txt (line 1))
Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB)
Collecting scipy==1.15.3 (from -r requirements_npu.txt (line 2))
Downloading scipy-1.15.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (61 kB)
Collecting sentencepiece==0.1.99 (from -r requirements_npu.txt (line 3))
Downloading sentencepiece-0.1.99-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (7.7 kB)
Collecting soundfile==0.12.1 (from -r requirements_npu.txt (line 4))
Downloading soundfile-0.12.1-py2.py3-none-any.whl.metadata (14 kB)
Collecting tiktoken==0.6.0 (from -r requirements_npu.txt (line 5))
Downloading tiktoken-0.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (6.6 kB)
ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11; 1.6.2 Requires-Python >=3.7,<3.10; 1.6.3 Requires-Python >=3.7,<3.10; 1.7.0 Requires-Python >=3.7,<3.10; 1.7.1 Requires-Python >=3.7,<3.10; 1.7.2 Requires-Python >=3.7,<3.11; 1.7.3 Requires-Python >=3.7,<3.11; 1.8.0 Requires-Python >=3.8,<3.11; 1.8.0rc1 Requires-Python >=3.8,<3.11; 1.8.0rc2 Requires-Python >=3.8,<3.11; 1.8.0rc3 Requires-Python >=3.8,<3.11; 1.8.0rc4 Requires-Python >=3.8,<3.11; 1.8.1 Requires-Python >=3.8,<3.11
ERROR: Could not find a version that satisfies the requirement torch==2.3.1+cpu (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.6.0, 2.6.0+cpu, 2.7.0, 2.7.0+cpu, 2.7.1, 2.7.1+cpu, 2.8.0, 2.8.0+cpu, 2.9.0, 2.9.0+cpu, 2.9.1, 2.9.1+cpu, 2.10.0, 2.10.0+cpu, 2.11.0, 2.11.0+cpu)
ERROR: No matching distribution found for torch==2.3.1+cpu

问题二. 我手动修改torch等版本号后,继续运行python -m pip install -r requirements_npu.txt --no-build-isolation报错如下:
Collecting pynini==2.1.5 (from WeTextProcessing==1.0.3->-r requirements_npu.txt (line 14))
Downloading pynini-2.1.5.tar.gz (627 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 627.6/627.6 kB 6.3 MB/s 0:00:00
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [17 lines of output]
Traceback (most recent call last):
File "/usr/local/python3.11.14/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in
main()
File "/usr/local/python3.11.14/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.14/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 175, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.14/lib/python3.11/site-packages/setuptools/build_meta.py", line 374, in prepare_metadata_for_build_wheel
self.run_setup()
File "/usr/local/python3.11.14/lib/python3.11/site-packages/setuptools/build_meta.py", line 512, in run_setup
super().run_setup(setup_script=setup_script)
File "/usr/local/python3.11.14/lib/python3.11/site-packages/setuptools/build_meta.py", line 317, in run_setup
exec(code, locals())
File "", line 22, in
ModuleNotFoundError: No module named 'Cython'
[end of output]

问题三:解决完以上依赖包后,运行python glmtts_inference.py --data=example_zh --exp_name=_test --use_cache会报错如下:

python glmtts_inference.py --data=example_zh --exp_name=_test --use_cache

/usr/local/python3.11.14/lib/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:347: 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.load, torch.set_default_device, torch.get_device_module, torch.sparse_compressed_tensor, 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/python3.11.14/lib/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:276: 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/python3.11.14/lib/python3.11/site-packages/librosa/util/files.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import resource_filename
onnxruntime cpuid_info warning: Unknown CPU vendor. cpuinfo_vendor value: 15
Warning: failed to import ttsfrd, use WeTextProcessing instead
[load_quantize_encoder] start. model_path='ckpt/speech_tokenizer'
Configured for 24kHz frontend.
/usr/local/python3.11.14/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:123: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'CANNExecutionProvider, CPUExecutionProvider'
warnings.warn(
2026-04-15 10:41:28,843 WETEXT INFO building fst for zh_normalizer ...
INFO: building fst for zh_normalizer ...
2026-04-15 10:41:58,892 WETEXT INFO done
INFO: done
2026-04-15 10:41:58,893 WETEXT INFO fst path: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/zh_tn_tagger.fst
INFO: fst path: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/zh_tn_tagger.fst
2026-04-15 10:41:58,893 WETEXT INFO /usr/local/python3.11.14/lib/python3.11/site-packages/tn/zh_tn_verbalizer.fst
INFO: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/zh_tn_verbalizer.fst
2026-04-15 10:41:58,898 WETEXT INFO found existing fst: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/en_tn_tagger.fst
INFO: found existing fst: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/en_tn_tagger.fst
2026-04-15 10:41:58,898 WETEXT INFO /usr/local/python3.11.14/lib/python3.11/site-packages/tn/en_tn_verbalizer.fst
INFO: /usr/local/python3.11.14/lib/python3.11/site-packages/tn/en_tn_verbalizer.fst
2026-04-15 10:41:58,898 WETEXT INFO skip building fst for en_normalizer ...
INFO: skip building fst for en_normalizer ...
Loading checkpoint shards: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 27.98it/s]
Loading HiFT model from ckpt/hift/hift.pt on cuda...
/home/lsc/wujian/glm_tts/GLM-TTS/utils/file_utils.py:32: ResourceWarning: unclosed file <_io.TextIOWrapper name='examples/example_zh.jsonl' mode='r' encoding='utf-8'>
lines = open(jsonl_file_path, encoding='utf-8').readlines()
0%| | 0/10 [00:00<?, ?it/s]ERROR: Error processing 0: Could not load libtorchcodec. Likely causes:
1. FFmpeg is not properly installed in your environment. We support
versions 4, 5, 6, 7, and 8, and we attempt to load libtorchcodec
for each of those versions. Errors for versions not installed on
your system are expected; only the error for your installed FFmpeg
version is relevant. On Windows, ensure you've installed the
"full-shared" version which ships DLLs.
2. The PyTorch version (2.9.0+cpu) is not compatible with
this version of TorchCodec. Refer to the version compatibility
table:
https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
3. Another runtime dependency; see exceptions below.

    The following exceptions were raised as we tried to load libtorchcodec:

[start of libtorchcodec loading traceback]
FFmpeg version 8:
Traceback (most recent call last):
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torch/_ops.py", line 1488, in load_library
ctypes.CDLL(path)
File "/usr/local/python3.11.14/lib/python3.11/ctypes/init.py", line 376, in init
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: libnvrtc.so.13: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torchcodec/_internally_replaced_utils.py", line 93, in load_torchcodec_shared_libraries
torch.ops.load_library(core_library_path)
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torch/_ops.py", line 1490, in load_library
raise OSError(f"Could not load this library: {path}") from e
OSError: Could not load this library: /usr/local/python3.11.14/lib/python3.11/site-packages/torchcodec/libtorchcodec_core8.so

FFmpeg version 7:
Traceback (most recent call last):
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torch/_ops.py", line 1488, in load_library
ctypes.CDLL(path)
File "/usr/local/python3.11.14/lib/python3.11/ctypes/init.py", line 376, in init
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: libnvrtc.so.13: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torchcodec/_internally_replaced_utils.py", line 93, in load_torchcodec_shared_libraries
torch.ops.load_library(core_library_path)
File "/usr/local/python3.11.14/lib/python3.11/site-packages/torch/_ops.py", line 1490, in load_library
raise OSError(f"Could not load this library: {path}") from e
OSError: Could not load this library: /usr/local/python3.11.14/lib/python3.11/site-packages/torchcodec/libtorchcodec_core7.so

Who can help? / 谁可以帮助到您?

No response

Information / 问题信息

  • The official example scripts / 官方的示例脚本
  • My own modified scripts / 我自己修改的脚本和任务

Reproduction / 复现过程

按照README文档操作

Expected behavior / 期待表现

在昇腾NPU上能按照指导说明正常安装部署并且运行起来

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions