已合并
安装脚本新增默认安装torch及指定默认abi版本 #2118
dovahkiiin创建于 6月11日
安装脚本新增默认安装torch及指定默认abi版本 #2118
已合并
共 1 个文件变更+20-0
| @@ -582,6 +582,26 @@ function upgrade() { | |||
| 582 | 582 | ||
| 583 | function get_torch_cxx11_abi() { | 583 | function get_torch_cxx11_abi() { |
| 584 | local abi | 584 | local abi |
| 585 | + local res | ||
| 586 | + local pip_ret | ||
| 587 | + local torch_install_timeout=300 | ||
| 588 | + local torch_http_timeout=60 | ||
| 589 | + | ||
| 590 | + res=$(TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -W ignore -c "import torch" 2>/dev/null || echo "torch_not_exist") | ||
| 591 | + if [ "$res" == "torch_not_exist" ]; then | ||
| 592 | + print "WARNING" "Torch is not installed, installing torch 2.9 by default..." >&2 | ||
| 593 | + timeout "${torch_install_timeout}" pip install --timeout "${torch_http_timeout}" "torch>=2.9.0,<2.10.0" > /dev/null 2>&1 | ||
| 594 | + pip_ret=$? | ||
| 595 | + if [ $pip_ret -ne 0 ]; then | ||
| 596 | + if [ $pip_ret -eq 124 ]; then | ||
| 597 | + print "WARNING" "Torch installation timed out after ${torch_install_timeout}s, using default CXX11 ABI: 1." >&2 | ||
| 598 | + else | ||
| 599 | + print "WARNING" "Failed to install torch, using default CXX11 ABI: 1." >&2 | ||
| 600 | + fi | ||
| 601 | + echo "1" | ||
| 602 | + return 0 | ||
| 603 | + fi | ||
| 604 | + fi | ||
| 585 | 605 | ||
| 586 | abi=$(TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -W ignore - <<'PY' | 606 | abi=$(TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -W ignore - <<'PY' |
| 587 | import sys | 607 | import sys |