Skip to content

Commit

Permalink
Add NM_ARCH env for deepsparse
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Murdaca <fmurdaca@redhat.com>
  • Loading branch information
Francesco Murdaca committed Sep 30, 2021
1 parent 42c8499 commit a2cdb65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions manifests/overlays/nm-inference/deploymentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ spec:
value: "1"
- name: THOTH_AIDEVSECOPS_MODEL_VERSION
value: "torch-210921164335-c352fe9b17e2f837_mnist_classification_pruned"
- name: NM_ARCH
value: "avx512"
imagePullPolicy: Always
ports:
- containerPort: 8080
Expand Down
2 changes: 1 addition & 1 deletion manifests/overlays/pytorch-inference/deploymentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
env:
- name: WEB_CONCURRENCY
value: "1"
- name: USE_PYTORCH
- name: TUTORIAL_USE_PYTORCH
value: "1"
- name: THOTH_AIDEVSECOPS_MODEL_VERSION
value: "torch-210921163030-5341ad0f6f389a55"
Expand Down
2 changes: 1 addition & 1 deletion src/pytorch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ def predict(self, image):
with torch.no_grad():
output, last_layer = self.model(image_)
pred_y = torch.max(output, 1)[1].data.squeeze()
return pred_y, output.tolist()[0][pred_y]
return pred_y, last_layer.tolist()[0][pred_y]
27 changes: 21 additions & 6 deletions wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,35 @@
from src.neural_magic_model import Model as NeuralMagicModel

nm_model = NeuralMagicModel()
# custom metric to expose model version
model_version_metric = prometheus_metrics.info(
"aidevsecops_tutorial_model_info",
"Model version deployed",
version=nm_model.model_version, # label
)

elif USE_PYTORCH:
from src.pytorch_model import Model as PytorchModel

pytorch_model = PytorchModel()
# custom metric to expose model version
model_version_metric = prometheus_metrics.info(
"aidevsecops_tutorial_model_info",
"Model version deployed",
version=pytorch_model.model_version, # label
)

else:
from src.model import Model as TensorflowModel

model = TensorflowModel()

# custom metric to expose model version
model_version_metric = prometheus_metrics.info(
"aidevsecops_tutorial_model_info",
"Model version deployed",
version=model.model_version, # label
)
# custom metric to expose model version
model_version_metric = prometheus_metrics.info(
"aidevsecops_tutorial_model_info",
"Model version deployed",
version=model.model_version, # label
)


@application.before_first_request
Expand Down

0 comments on commit a2cdb65

Please sign in to comment.