Skip to content

Latest commit

 

History

History
146 lines (135 loc) · 3.49 KB

run-pytorch-experiment.md

File metadata and controls

146 lines (135 loc) · 3.49 KB

Run PyTorch Experiment Guide

Experiment Spec

The experiment is represented in JSON or YAML format.

YAML Format:

meta:
  name: pytorch-mnist-yaml
  namespace: default
  framework: PyTorch
  cmd: python /var/mnist.py --backend gloo
  envVars:
    ENV_1: ENV1
environment:
  image: apache/submarine:pytorch-dist-mnist-1.0
spec:
  Master:
    replicas: 1
    resources: cpu=1,memory=1024M
  Worker:
    replicas: 1
    resources: cpu=1,memory=1024M

JSON Format:

{
  "meta": {
    "name": "pytorch-mnist-json",
    "namespace": "default",
    "framework": "PyTorch",
    "cmd": "python /var/mnist.py --backend gloo",
    "envVars": {
      "ENV_1": "ENV1"
    }
  },
  "environment": {
    "image": "apache/submarine:pytorch-dist-mnist-1.0"
  },
  "spec": {
    "Master": {
      "replicas": 1,
      "resources": "cpu=1,memory=1024M"
    },
    "Worker": {
      "replicas": 1,
      "resources": "cpu=1,memory=1024M"
    }
  }
}

Create Experiment by REST API

POST /api/v1/experiment

Example Request

curl -X POST -H "Content-Type: application/json" -d '
{
  "meta": {
    "name": "pytorch-mnist-json",
    "namespace": "default",
    "framework": "PyTorch",
    "cmd": "python /var/mnist.py --backend gloo",
    "envVars": {
      "ENV_1": "ENV1"
    }
  },
  "environment": {
    "image": "apache/submarine:pytorch-dist-mnist-1.0"
  },
  "spec": {
    "Master": {
      "replicas": 1,
      "resources": "cpu=1,memory=1024M"
    },
    "Worker": {
      "replicas": 1,
      "resources": "cpu=1,memory=1024M"
    }
  }
}
' http://127.0.0.1:8080/api/v1/experiment

Example Response:

{
    "status": "OK",
    "code": 200,
    "result": {
        "experimentId": "experiment_1592057447228_0002",
        "name": "mnist",
        "uid": "38e39dcd-77d4-11ea-8dbb-0242ac110003",
        "status": "Accepted",
        "acceptedTime": "2020-06-13T22:19:29.000+08:00",
        "spec": {
            "meta": {
                "name": "pytorch-mnist-json",
                "namespace": "default",
                "framework": "PyTorch",
                "cmd": "python /var/mnist.py --backend gloo",
                "envVars": {
                    "ENV_1": "ENV1"
                }
            },
            "environment": {
                "image": "apache/submarine:pytorch-dist-mnist-1.0"
            },
            "spec": {
                "Master": {
                    "replicas": 1,
                    "resources": "cpu=1,memory=1024M"
                },
                "Worker": {
                    "replicas": 1,
                    "resources": "cpu=1,memory=1024M"
                }
            }
        }
    }
}

More info see Experiment API Reference.