使用pyannote.audio时libtorchaudio.pyd存在却无法找到的错误求助
解决libtorchaudio.pyd找不到但文件存在的问题(PyTorch/英特尔硬件场景)
运行pyannote.audio测试程序时触发错误:
FileNotFoundError: Could not find module C:\Users\pedroaf\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\lib\libtorchaudio.pyd' (or one of its dependencies). Try using the full path with constructor syntax.目标文件实际存在,已尝试卸载重装torchaudio、安装intel-extension-for-pytorch、搭建conda环境,均无效;怀疑是英特尔硬件不支持CUDA导致的问题。
解决方案
安装适配英特尔硬件的CPU版PyTorch/ torchaudio
若当前安装的是CUDA版本的库,英特尔硬件无法兼容。卸载现有版本后重装纯CPU版:# pip方式 pip uninstall torch torchaudio -y pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu # conda方式 conda uninstall torch torchaudio -y conda install torch torchaudio cpuonly -c pytorch补全VC++运行库依赖
错误提示中的“依赖项缺失”大概率是微软Visual C++ Redistributable未安装或版本过低。安装2019及以上版本的VC++运行库,重启系统后再测试。排查文件访问权限
确认Python进程拥有读取libtorchaudio.pyd所在目录的权限,暂时关闭杀毒软件或防火墙,避免其拦截文件读取操作。手动指定库加载路径
在代码开头添加路径配置,强制Python加载指定目录下的库:import os lib_path = r"C:\Users\pedroaf\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\lib" os.add_dll_directory(lib_path) # 后续导入pyannote相关模块 from pyannote.audio import Pipeline
内容的提问来源于stack exchange,提问作者Pedro Fukuda
相关产品推荐
相关产品推荐

