Skip to content

Commit

Permalink
onnxruntime / onnxruntime-gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Apr 18, 2024
1 parent 400d648 commit a6ce04d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 15 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ def install_requirements(req_file):
)


def install_onnxruntime():
"""
Install onnxruntime or onnxruntime-gpu based on the availability of CUDA.
onnxruntime and onnxruntime-gpu can not be installed together.
"""
if not launch.is_installed("onnxruntime") and not launch.is_installed("onnxruntime-gpu"):
import torch.cuda as cuda # torch import head to improve loading time
onnxruntime = 'onnxruntime-gpu' if cuda.is_available() else 'onnxruntime'
launch.run_pip(
f'install {onnxruntime}',
f"sd-webui-controlnet requirement: {onnxruntime}",
)


def try_install_from_wheel(pkg_name: str, wheel_url: str, version: Optional[str] = None):
current_version = get_installed_version(pkg_name)
if current_version is not None:
Expand Down Expand Up @@ -140,6 +154,7 @@ def try_remove_legacy_submodule():


install_requirements(main_req_file)
install_onnxruntime()
try_install_insight_face()
try_install_from_wheel(
"handrefinerportable",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
fvcore
mediapipe
onnxruntime
opencv-python>=4.8.0
svglib
addict
Expand Down

0 comments on commit a6ce04d

Please sign in to comment.