BigVGAN 是 NVIDIA 发布的一个通用神经声码器 (Neural Vocoder),用于从梅尔频谱 (Mel Spectrogram) 生成高质量音频。
本模型是 v2-22khz-80band-256x 版本,支持 22 kHz 采样率、80 频段、256 倍上采样。
| 属性 | 值 |
|---|---|
| 模型类型 | 神经声码器 (Neural Vocoder) |
| 采样率 | 22,050 Hz |
| 梅尔频段 | 80 |
| 上采样率 | 256x |
| 参数量 | ~112M |
| 权重文件大小 | ~449 MB |
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| 操作系统 | CentOS 7.6+ / Ubuntu 18.04+ | 支持主流 Linux 发行版 |
| CANN | 5.0.RC2+ | 华为昇腾计算架构 |
| Python | 3.10 / 3.12 | 推荐 3.10+ |
| PyTorch | 2.0.0+ | 推荐 2.10 |
| torch_npu | 与 PyTorch 版本匹配 | 昇腾 PyTorch 扩展 |
| librosa | 最新版 | 音频处理 |
| numpy | 最新版 | 数值计算 |
# 1) 激活已预装 torch / torch_npu 的 conda 环境
conda activate pt2100
# 2) 安装模型依赖(使用华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple \
librosa numpy
# 3) 验证环境
python -c "
import torch, torch_npu
print('torch:', torch.__version__)
print('torch_npu:', torch_npu.__version__)
print('NPU 可用:', torch.npu.is_available())
"# 进入适配目录
cd /workspace/agent1/bigvgan_v2_22khz_80band_256x-ascend
# 确认上游权重存在
ls -la /workspace/agent2/nvidia/bigvgan_v2_22khz_80band_256x/
# 期望输出:config.json bigvgan_generator.pt (~449MB) bigvgan.py ...# 检查 NPU 设备状态
npu-smi info
# 验证 torch_npu 安装
python -c "import torch; import torch_npu; print('NPU 可用:', torch.npu.is_available())"# 基本用法:默认参数
python inference.py --device npu:0
# 查看 NPU 显存使用
python inference.py --device npu:0 --show_npu_memory
# 指定其他 NPU 卡
python inference.py --device npu:1conda activate pt2100
cd /workspace/agent1/bigvgan_v2_22khz_80band_256x-ascend
python inference.py --device npu:0实际输出:
[W822 09:19:05.452068410 FunctionLoader.cpp:48] Warning: LD_PRELOAD detected...
[W822 09:19:17.847640710 NPUCachingAllocator.cpp:201] Warning: The current CANN and Soc versions require processing for 32 padding size, with memory allocation. (function operator())
============================================================
BigVGAN-v2-22khz-80band-256x 昇腾 NPU 推理
============================================================
[Device] npu:0
[Model Path] /workspace/agent2/nvidia/bigvgan_v2_22khz_80band_256x
[Loading] BigVGAN model...
Loading config.json from local directory
Loading weights from local directory
Model loaded from pretrained
Removing weight norm...
[Model Loaded] Allocated: 0.42 GB, Reserved: 0.46 GB
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 103.7 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 3951 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1251206 | python | 582 |
+===========================+===============+====================================================+
[Creating] Dummy audio input (1 second at 22050 Hz)...
[Input Audio] Shape: torch.Size([1, 22050]), Duration: 1.00s
[Computing Mel Spectrogram]...
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 104.1 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 4009 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1251206 | python | 640 |
+===========================+===============+====================================================+
[Mel Spectrogram] Shape: torch.Size([1, 80, 86])
[Running Audio Generation]...
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 108.2 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 4063 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1251206 | python | 694 |
+===========================+===============+====================================================+
[Results]
Generated audio shape: torch.Size([1, 1, 22016])
Generated audio duration: 1.00s
Generated audio range: [-0.5875, 0.5213]
[Memory After Inference] Allocated: 0.42 GB, Reserved: 0.49 GB
[Done]✅ 验证要点:
(1, 1, 22016) - 1 秒音频解决方案:
source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh)npu-smi info 检查设备状态解释:BigVGAN 支持自定义 CUDA kernel 加速推理,但在 NPU 上需要设置 use_cuda_kernel=False。已在脚本中默认关闭。
解释:使用随机噪声输入时,生成的是无意义音频。实际使用时需要输入真实梅尔频谱。
bigvgan_v2_22khz_80band_256x-ascend/
├── inference.py # 推理脚本(torch_npu 推理)
├── README.md # 本文档
├── requirements.txt # 依赖列表
└── assets/ # 资源占位目录上游权重目录(只读,未被修改):
/workspace/agent2/nvidia/bigvgan_v2_22khz_80band_256x/
├── config.json # BigVGAN 配置
├── bigvgan_generator.pt # 生成器权重(约 449MB)
├── bigvgan.py # 模型代码
├── meldataset.py # 梅尔频谱工具
└── README.md # 原始文档# BigVGAN-v2-22khz-80band-256x 昇腾 NPU 推理环境依赖
# 核心依赖(必须)
torch>=2.0.0
torch_npu
librosa
numpy使用方式:
# 激活环境
conda activate pt2100
# 安装依赖(华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple -r requirements.txt