Skip to content

Instantly share code, notes, and snippets.

@sub-mod
Created April 14, 2020 13:17
Show Gist options
  • Save sub-mod/9b69424124485cd2138444bad1756cd0 to your computer and use it in GitHub Desktop.
Save sub-mod/9b69424124485cd2138444bad1756cd0 to your computer and use it in GitHub Desktop.
Use OMP_NUM_THREADS=1 for Running Pytorch on Openshift with 1CPU

Use OMP_NUM_THREADS=1 for Running Pytorch on Openshift with 1CPU
Else MKL will spawn threads for all the cpus it can see from the pod.

apiVersion: v1
kind: Template
metadata:
  name: playground
  labels:
    app: playground

parameters:
  - description: Registry the ImageStream to be use lives in
    displayName: ImageStream Registry
    required: true
    name: IMAGE
    value: "quay.io/fridex/torch-matmul:latest"

  - description: Job identifier to be generated to distinguish multiple submissions.
    from: '[a-z0-9]{4}'
    generate: expression
    name: IDENTIFIER

  - description: Number of CPUs to assign.
    name: CPU
    value: "1"

  - description: Memory to be assigned.
    name: MEMORY
    value: "1Gi"

objects:
  - apiVersion: batch/v1
    kind: Job
    metadata:
      name: "playground-${IDENTIFIER}"
      labels:
        app: playground
    spec:
      template:
        metadata:
          labels:
            app: playground
        spec:
          restartPolicy: Never
          containers:
            - name: playground
              env:
                - name: "OMP_NUM_THREADS"
                  value: "1"
              image: "${IMAGE}"
              resources:
                limits:
                  memory: "${MEMORY}"
                  cpu: "${CPU}"
                requests:
                  memory: "${MEMORY}"
                  cpu: "${CPU}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment