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

Use cpu provider for embeddings models #13806

Merged
merged 1 commit into from
Sep 17, 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
28 changes: 3 additions & 25 deletions frigate/embeddings/functions/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,11 @@ def _load_models(

@staticmethod
def _load_model(path: str, silent: bool):
providers = []
options = []

for provider in ort.get_available_providers():
if provider == "TensorrtExecutionProvider":
continue
elif provider == "OpenVINOExecutionProvider":
# TODO need to verify openvino works correctly
os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
providers.append(provider)
options.append(
{
"cache_dir": "/config/model_cache/openvino/ort",
"device_type": "GPU",
}
)
else:
providers.append(provider)
options.append({})
providers = ["CPUExecutionProvider"]

try:
if os.path.exists(path):
return ort.InferenceSession(
path, providers=providers, provider_options=options
)
return ort.InferenceSession(path, providers=providers)
else:
raise FileNotFoundError(
errno.ENOENT,
Expand Down Expand Up @@ -104,9 +84,7 @@ def _load_model(path: str, silent: bool):
f.flush()
# Finally move the temporary file to the correct location
temporary_filename.rename(path)
return ort.InferenceSession(
path, providers=provider, provider_options=options
)
return ort.InferenceSession(path, providers=providers)


class ClipEmbedding(EmbeddingFunction):
Expand Down
Loading