Creating a PyTorchJob
Function
This API is used to create a PyTorchJob.
PyTorch job (PyTorchJob) is a PyTorch-based Kubernetes custom resource that you can use to run PyTorch training jobs.
URI
POST /apis/kubeflow.org/v1/namespaces/{namespace}/pytorchjobs
| Parameter | Mandatory | Description |
|---|---|---|
| namespace | Yes | Object name and auth scope, such as for teams and projects. |
| Parameter | Mandatory | Description |
|---|---|---|
| pretty | No | If 'true', then the output is pretty printed. |
Request
Request parameters
For the description about request parameters, see Table 165.
Example request
{
"apiVersion": "kubeflow.org/v1",
"kind": "PyTorchJob",
"metadata": {
"name": "pytorch-test"
},
"spec": {
"pytorchReplicaSpecs": {
"Master": {
"replicas": 1,
"restartPolicy": "Never",
"template": {
"spec": {
"containers": [
{
"name": "pytorch",
"image": "*.*.*.215:20202/gcs/pytorch-cpu:v1",
"command": [
"python",
"/var/mnist.py"
],
"args": [
"--backend",
"gloo"
],
"resources": {
"limits": {
"cpu": 2,
"memory": "4Gi"
},
"requests": {
"cpu": 2,
"memory": "4Gi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
]
}
}
},
"Worker": {
"replicas": 1,
"restartPolicy": "OnFailure",
"template": {
"spec": {
"containers": [
{
"name": "pytorch",
"image": "*.*.*.215:20202/gcs/pytorch-cpu:v1",
"command": [
"python",
"/var/mnist.py"
],
"args": [
"--backend",
"gloo"
],
"resources": {
"limits": {
"cpu": 2,
"memory": "4Gi"
},
"requests": {
"cpu": 2,
"memory": "4Gi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
]
}
}
}
}
}
} Response
Response parameters
For the description about response parameters, see Table 165.
Example response
{
"apiVersion": "kubeflow.org/v1",
"kind": "PyTorchJob",
"metadata": {
"creationTimestamp": "2019-07-24T10:29:45Z",
"generation": 1,
"name": "pytorch-test",
"namespace": "kube-test",
"resourceVersion": "72516798",
"selfLink": "/apis/kubeflow.org/v1/namespaces/kube-test/pytorchjobs/pytorch-test",
"uid": "f4c79668-adfd-11e9-8041-340a9837e2a7"
},
"spec": {
"pytorchReplicaSpecs": {
"Master": {
"replicas": 1,
"restartPolicy": "Never",
"template": {
"spec": {
"containers": [
{
"args": [
"--backend",
"gloo"
],
"command": [
"python",
"/var/mnist.py"
],
"image": "*.*.*.215:20202/gcs/pytorch-cpu:v1",
"name": "pytorch",
"resources": {
"limits": {
"cpu": 2,
"memory": "4Gi"
},
"requests": {
"cpu": 2,
"memory": "4Gi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
]
}
}
},
"Worker": {
"replicas": 1,
"restartPolicy": "OnFailure",
"template": {
"spec": {
"containers": [
{
"args": [
"--backend",
"gloo"
],
"command": [
"python",
"/var/mnist.py"
],
"image": "*.*.*.215:20202/gcs/pytorch-cpu:v1",
"name": "pytorch",
"resources": {
"limits": {
"cpu": 2,
"memory": "4Gi"
},
"requests": {
"cpu": 2,
"memory": "4Gi"
}
}
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
]
}
}
}
}
},
"status": {
}
} Status Code
| Status Code | Description |
|---|---|
| 200 | OK |
| 201 | Created |
| 202 | Accepted |
| 401 | Unauthorized |
| 400 | Badrequest |
| 500 | Internal error |
| 403 | Forbidden |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot