Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce onnx memory usage #14285

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion frigate/util/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ def get_ort_providers(
force_cpu: bool = False, openvino_device: str = "AUTO", requires_fp16: bool = False
) -> tuple[list[str], list[dict[str, any]]]:
if force_cpu:
return (["CPUExecutionProvider"], [{}])
return (
["CPUExecutionProvider"],
[
{
"arena_extend_strategy": "kSameAsRequested",
}
],
)

providers = ort.get_available_providers()
options = []
Expand All @@ -28,6 +35,7 @@ def get_ort_providers(
if not requires_fp16 or os.environ.get("USE_FP_16", "True") != "False":
options.append(
{
"arena_extend_strategy": "kSameAsRequested",
"trt_fp16_enable": requires_fp16,
"trt_timing_cache_enable": True,
"trt_engine_cache_enable": True,
Expand All @@ -41,10 +49,17 @@ def get_ort_providers(
os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
options.append(
{
"arena_extend_strategy": "kSameAsRequested",
"cache_dir": "/config/model_cache/openvino/ort",
"device_type": openvino_device,
}
)
elif provider == "CPUExecutionProvider":
options.append(
{
"arena_extend_strategy": "kSameAsRequested",
}
)
else:
options.append({})

Expand Down