-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New model spec metadata format with runtime and model resource inform…
…ation
- Loading branch information
Showing
5 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from nos import hub | ||
from nos.common import TaskType | ||
from nos.common.spec import ModelResources, ModelSpec, ModelSpecMetadata, _metadata_path | ||
from nos.logging import logger | ||
|
||
|
||
spec: ModelSpec = hub.load_spec(task=TaskType.IMAGE_EMBEDDING, model_name="openai/clip") | ||
spec._metadata = ModelSpecMetadata( | ||
name=spec.name, | ||
task=spec.task, | ||
resources={ | ||
"cpu": ModelResources(runtime="cpu", device="cpu", device_memory=2 * 1024**3, cpus=2), | ||
"gpu": ModelResources(runtime="gpu", device="cuda", device_memory=2 * 1024**3, cpus=1), | ||
}, | ||
) | ||
|
||
path = _metadata_path(spec) | ||
if not path.exists(): | ||
path.parent.mkdir(parents=True, exist_ok=True) | ||
spec._metadata.to_json(path) | ||
logger.info(f"Saved metadata to {path}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters