后端启动stable_diffusion的api接口
nohup python launch.py --use-cpu all --skip-torch-cuda-test --api --api-log --listen --server-name 192.168.1.204 > /home/third_party_app/llm/stable-diffusion-webui/logs/all.log 2>&1 &
服务接口
http://192.168.1.204:7860/docs
错误描述
Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check https://github.com/pytorch/vision#installation for the compatibility matrix. Please check your PyTorch version with torch.__version__ and your torchvision version with torchvision.__version__ and verify if they are compatible, and if not please reinstall torchvision so that it matches your PyTorch install.
解决方案
-
原因:
遇到“Couldn't load custom C++ ops”这样的错误,通常意味着 PyTorch 和 torchvision 之间的版本不兼容。
检查版本兼容性:
import torch
import torchvision
print("PyTorch version:", torch.__version__)
print("Torchvision version:", torchvision.__version__)
重新安装 torchvision
pip uninstall torchvision
pip install torchvision