-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_ls_job.py
73 lines (68 loc) · 2.14 KB
/
run_ls_job.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config", type=str)
parser.add_argument("-m", "--model_type", type=str)
parser.add_argument("-n", "--exp_name", type=str, default="default")
args = parser.parse_args()
yaml_config = \
f'''
apiVersion: batch/v1
kind: Job
metadata:
name: vthumuluri-job-ls-{args.config}-{args.model_type.replace("_","-")}-{args.exp_name}
namespace: ai-md
labels:
user: vthumuluri
spec:
ttlSecondsAfterFinished: 36000 # 100 minute to delete completed jobs
template:
spec:
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: nvidia.com/gpu.product
# operator: In
# values:
# - NVIDIA-A10
#- NVIDIA-GeForce-RTX-2080-Ti
containers:
- name: gpu-container
image: gitlab-registry.nrp-nautilus.io/vthumuluri/aimd
command:
- "sh"
- "-c"
args:
- "cd /home/AIMD && conda init && . /opt/conda/etc/profile.d/conda.sh && conda activate pytorch && pip install cmake cvxpy faiss-gpu && pip install loss-landscapes && python analyze_latent_space.py --config {args.config} --model_type {args.model_type} --exp_name {args.exp_name}"
resources:
requests:
cpu: "12"
memory: "16Gi"
nvidia.com/gpu: 0
ephemeral-storage: 10Gi
limits:
cpu: "12"
memory: "16Gi"
nvidia.com/gpu: 0
ephemeral-storage: 10Gi
volumeMounts:
- name: dshm
mountPath: /dev/shm
- name: vthumuluri-slow-vol-aimd
mountPath: /home
volumes:
- name: dshm
emptyDir:
medium: Memory
- name: vthumuluri-slow-vol-aimd
persistentVolumeClaim:
claimName: vthumuluri-slow-vol-aimd
restartPolicy: Never
backoffLimit: 0
'''
with open("temp_file.yaml", "w") as f:
f.write(yaml_config)
os.system(f'kubectl create -f temp_file.yaml')
#os.system(f'rm temp_file.yaml')