github.com/bigcommerce/nomad@v0.9.3-bc/terraform/examples/tensorrt/tensorrt-demo.nomad (about)

     1  job "tensorrt" {
     2    datacenters = ["dc1"]
     3  
     4    group "back" {
     5      task "rtserver" {
     6        driver = "docker"
     7        config {
     8          image = "nvcr.io/nvidia/tensorrtserver:19.02-py3"
     9          command = "trtserver"
    10          args = [
    11            "--model-store=${NOMAD_TASK_DIR}/models"
    12          ]
    13          shm_size=1024
    14          port_map { 
    15            http = 8000
    16            grpc = 8001 
    17            metrics = 8002 
    18          }
    19          ulimit {
    20            memlock = "-1"
    21            stack = "67108864" 
    22          }
    23        }
    24       
    25        service {
    26          port = "http"
    27          tags = ["http"]
    28          check {
    29            type     = "http"
    30            port     = "http"
    31            path     = "/api/health/ready"
    32            interval = "5s"
    33            timeout  = "1s"
    34          }
    35          check_restart {
    36            grace = "30s"
    37          }
    38        }
    39      
    40        # load the example model into ${NOMAD_TASK_DIR}/models
    41        artifact {
    42          source      = "http://download.caffe2.ai.s3.amazonaws.com/models/resnet50/predict_net.pb"
    43          destination = "local/models/resnet50_netdef/1/model.netdef"
    44          mode = "file"
    45        }
    46        artifact {
    47          source      = "http://download.caffe2.ai.s3.amazonaws.com/models/resnet50/init_net.pb"
    48          destination = "local/models/resnet50_netdef/1/init_model.netdef"
    49          mode = "file"
    50        }
    51        artifact {
    52          source      = "https://raw.githubusercontent.com/NVIDIA/tensorrt-inference-server/v1.0.0/docs/examples/model_repository/resnet50_netdef/config.pbtxt"
    53          destination = "local/models/resnet50_netdef/config.pbtxt"
    54          mode = "file"
    55        }
    56        artifact {
    57          source      = "https://raw.githubusercontent.com/NVIDIA/tensorrt-inference-server/v1.0.0/docs/examples/model_repository/resnet50_netdef/resnet50_labels.txt"
    58          destination = "local/models/resnet50_netdef/resnet50_labels.txt"
    59          mode = "file"
    60        }
    61  
    62        resources {
    63          cpu = 8192
    64          memory = 8192
    65          network {
    66            mbits = 10
    67            port "http" {} 
    68          }
    69  
    70          # an Nvidia GPU with >= 4GiB memory, preferably a Tesla
    71          device "nvidia/gpu" {
    72            count = 1
    73            constraint {
    74              attribute = "${device.attr.memory}"
    75              operator  = ">="
    76              value     = "4 GiB"
    77            }
    78            affinity {
    79              attribute = "${device.model}"
    80              operator = "regexp"
    81              value     = "Tesla"
    82            }
    83          }
    84        }
    85      }
    86    }
    87  
    88    group "front" {
    89      task "web" {
    90  
    91        driver = "docker"
    92  
    93        config {
    94          image = "renaudwastaken/tensorrt-frontend:latest"
    95          args = [
    96            "main.py", "${RTSERVER}"
    97          ]
    98          port_map { 
    99            http = 5000
   100          }
   101        }
   102  
   103        resources {
   104          cpu = 1024
   105          memory = 1024
   106          network {
   107            mbits = 10
   108            port "http" { static = "8888" }
   109          }
   110        }
   111  
   112        template {
   113          data = <<EOH
   114            RTSERVER = {{ with service "tensorrt-back-rtserver" }}{{ with index . 0 }} http://{{.Address }}:{{.Port }} {{ end }}{{ end }}
   115          EOH
   116          destination = "local/rtserver.env"
   117          env = true
   118        }
   119  
   120      }
   121    }
   122  
   123  }