安装完intel驱动的提示错误:PS F:\ai\fastapi> python app.py
Traceback (most recent call last):
File "F:\ai\fastapi\app.py", line 9, in <module>
import torch
File "\Program Files\Python310\lib\site-packages\torch\__init__.py", line 262, in <module>
_load_dll_libraries()
File "\Program Files\Python310\lib\site-packages\torch\__init__.py", line 258, in _load_dll_libraries
raise err
OSError: [WinError 126] 找不到指定的模块。 Error loading "\Program Files\Python310\lib\site-packages\torch\lib\aoti_custom_ops.dll" or one of its dependencies.

安装完Pytorch驱动的提示错误:
PS F:\ai\fastapi> python app.py
Traceback (most recent call last):
File "F:\ai\fastapi\app.py", line 9, in <module>
import torch
File "\Program Files\Python310\lib\site-packages\torch\__init__.py", line 278, in <module>
_load_dll_libraries()
File "\Program Files\Python310\lib\site-packages\torch\__init__.py", line 261, in _load_dll_libraries
raise err
OSError: [WinError 127] 找不到指定的程序。 Error loading "\Program Files\Python310\lib\site-packages\torch\lib\c10_xpu.dll" or one of its dependencies.

遇到:Error loading "盘符:\***\Python310\lib\site-packages\torch\lib\c10_xpu.dll" or one of its dependencies.返回只安装intel的驱动:

完全清理已安装的

# 1. 先完全清理
pip uninstall torch torchvision torchaudio intel-extension-for-pytorch pytorch-triton-xpu -y

# 2. 删除残留文件
$pythonDir = "D:\Program Files\Python310"
$torchDirs = @(
"$pythonDir\Lib\site-packages\torch",
"$pythonDir\Lib\site-packages\torchvision",
"$pythonDir\Lib\site-packages\torchaudio",
"$pythonDir\Lib\site-packages\intel_extension_for_pytorch",
"$pythonDir\Lib\site-packages\pytorch_triton_xpu"
)

foreach ($dir in $torchDirs) {
if (Test-Path $dir) {
Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "删除: $dir" -ForegroundColor Yellow
}
}

# 3. 重新安装(先试 CPU 版本)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu

# 4. 测试
python -c "import torch; print(f'PyTorch {torch.__version__} 安装成功'); print(f'可用设备: CPU')"

----
安装intel驱动后,查看已安装:

Powershell

PS E:\AI\driver\pytorch> pip list | Select-String "torch"

torch 2.5.1+cpu
torchaudio 2.5.1+cpu
torchsde 0.2.6
torchvision 0.20.1+cpu


登陆