class_docstr: Triton build logic for model builder
class_docstr_tok: ["Triton","build","logic","for","model","builder"]
docstr: Validation for triton, expand this as we include more backend support with more framework
code: def _validate_for_triton(
      self,
  ):
      """Validation for triton, expand this as we include more backend support with more framework"""
      try:
          import tritonclient.http as httpClient
  
          httpClient.__class__
      except ModuleNotFoundError:
          raise ImportError(
              (
                  "Launching Triton with ModelBuilder requires tritonClient[http] module. "
                  "but it was not found in your environemnt. "
                  "Checkout the instructions on the installation page of its repo: "
                  "https://github.com/triton-inference-server/client#getting-the-client-libraries-and-examples "
                  "And follow the ones that match your environment."
                  "Please note that you may need to restart your runtime after installation."
              )
          )
  
      if (
          self.mode == Mode.LOCAL_CONTAINER
          and not _has_nvidia_gpu()
          and self.image_uri
          and "cpu" not in self.image_uri
      ):
          # When customer does not have Nvidia GPU but tries to launch Triton in GPU mode in LOCAL_CONTAINER mode
          raise ValueError(
              (
                  "Your device does not have a Nvidia GPU. "
                  "Ubable to launch Triton container in GPU mode in your local machine. "
                  "Please provide a CPU version triton image to serve your model in LOCAL_CONTAINER mode. "
              )
          )
  
      if self.mode not in SUPPORTED_TRITON_MODE:
          raise ValueError(
              "%s mode is not supported with Triton model server."
              % self.mode
          )
  
      # Validate model path
      model_path = Path(self.model_path)
      if not model_path.exists():
          model_path.mkdir(parents=True)
      elif not model_path.is_dir():
          raise Exception(
              "model_path: %s is not a valid directory"
              % self.model_path
          )
  
      # Validate schema builder
      self.schema_builder._update_serializer_deserializer_for_triton()
      self.schema_builder._detect_dtype_for_triton()
  
      # Check python version - all SageMaker triton image are using python 3.8
      if not platform.python_version().startswith("3.8"):
          logger.warn(
              (
                  "SageMaker Triton image uses python 3.8, your python version: %s. "
                  "It is recommended to use the same python version to avoid incompatibility."
              )
              % platform.python_version()
          )
  
      if self.model:
          (
              self._framework,
              self._version,
          ) = _detect_framework_and_version(
              str(_get_model_base(self.model))
          )
  
          if self._framework not in SUPPORTED_TRITON_FRAMEWORK:
              raise ValueError(
                  "%s is not supported with Triton model server"
                  % self._framework
              )
  
      if self.inference_spec:
          if "conda" not in sys.executable.lower():
              raise ValueError(
                  (
                      "Invalid python environment %s, please use anaconda "
                      "or miniconda to manage your python environment "
                      "as it is required by Triton to capture "
                      "and pack your python dependencies."
                  )
                  % sys.executable
              )
  
imports: from __future__ import absolute_import
  import os
  import logging
  import platform
  from abc import abstractmethod
  from pathlib import Path
  import sys
  from typing import Type
  import shutil
  import subprocess
  from sagemaker import Session
  from sagemaker.model import Model
  from sagemaker.base_predictor import Predictor
  from sagemaker.serve.builder.schema_builder import SchemaBuilder
  from sagemaker.serve.mode.function_pointers import Mode
  from sagemaker.serve.detector.image_detector import _detect_framework_and_version, _get_model_base
  from sagemaker.serve.utils.local_hardware import _get_available_gpus
  from sagemaker.base_serializers import JSONSerializer
  from sagemaker.base_deserializers import JSONDeserializer
  from sagemaker.serve.detector.pickler import save_pkl
  from sagemaker.serve.model_server.triton.config_template import CONFIG_TEMPLATE
  from sagemaker.serve.validations.check_integrity import generate_secret_key, compute_hash
  from sagemaker.remote_function.core.serialization import _MetaData
label_desc: Use image node_id 2 for calling the Triton obj's underlying member method code with example usage: obj._validate_for_triton() without return types