Closed
Ascend 环境下 torch.classes.torchvision.GPUDecoder 无法注册 #3430
baoxuebin_2026Add on Jul 28Closed at Aug 5
Jul 28 Modify description of issue
Aug 4 Added label: bot-triaged
TorchNPU-Bot
Aug 4 Comments:
Aug 4 Comments:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


Aug 5 changed custom state from TODO to DONE
Aug 5 Close issue
Aug 5 Added label: resolved
环境信息:
🐛 问题描述:
在 Torch-NPU API 补齐任务中验证 `torch.classes.torchvision.GPUDecoder` 时,发现当前 Ascend NPU 环境下该 API 无法正常访问。 最初环境中未安装 `torchvision`,安装与 `torch==2.9.0` 对应的 `torchvision==0.24.0` 后,`torchvision` 可以正常导入,但 `torch.classes.torchvision.GPUDecoder` 仍无法注册,访问时会报错: `RuntimeError: Tried to instantiate class 'torchvision.GPUDecoder', but it does not exist! Ensure that it is registered via torch::class_` 进一步检查发现,当前 aarch64 环境下安装的 torchvision wheel 中存在 Python 加载入口 `torchvision/io/_load_gpu_decoder.py`,但包内未包含 `gpu_decoder.so`,因此该 C++ custom class 未注册到 `torch.classes.torchvision`。 该问题目前看起来更像是 torchvision GPU video decoder 扩展库在当前 Ascend/aarch64 环境下缺失,而不是 torch_npu Python API 层可直接补齐的问题。最小可复现示例:
import torch import torch_npu import torchvision print("torch:", torch.__version__) print("torch_npu:", torch_npu.__version__) print("torchvision:", torchvision.__version__) print("has torch.classes.torchvision:", hasattr(torch.classes, "torchvision")) try: print(torch.classes.torchvision.GPUDecoder) except Exception as e: print("GPUDecoder error:", type(e).__name__, str(e))执行方式:
source /usr/local/Ascend/ascend-toolkit/set_env.sh python3.11 repro_gpu_decoder.py实际运行结果:
补充验证:
find /home/HwHiAiUser/.local/lib/python3.11/site-packages/torchvision -maxdepth 2 -type f \( -name '*.so' -o -name '*gpu*' \) -print结果:
未发现
gpu_decoder.so。