diff --git a/backend/automl/views.py b/backend/automl/views.py index 73f3641..8523248 100644 --- a/backend/automl/views.py +++ b/backend/automl/views.py @@ -941,13 +941,13 @@ def post(self, request, format=None): } } - if gpu_mem_to_allocate > 0: - job_manifest['spec']['template']['spec']['containers'][0]['resources'] = {'limits': {'nvidia.com/gpu': gpu_mem_to_allocate}} - job_manifest['spec']['template']['spec']['containers'][0]['env'].append({'name': 'NVIDIA_VISIBLE_DEVICES', 'value': "all"}) - job_manifest['spec']['template']['spec']['runtimeClassName'] = 'nvidia' + if gpu_mem_to_allocate > 0: + job_manifest['spec']['template']['spec']['containers'][0]['resources'] = {'limits': {'nvidia.com/gpu': gpu_mem_to_allocate}} + job_manifest['spec']['template']['spec']['containers'][0]['env'].append({'name': 'NVIDIA_VISIBLE_DEVICES', 'value': "all"}) + job_manifest['spec']['template']['spec']['runtimeClassName'] = 'nvidia' - resp = api_instance.create_namespaced_job(body=job_manifest, namespace=settings.KUBE_NAMESPACE) - logging.info("Job created. status='%s'" % str(resp.status)) + resp = api_instance.create_namespaced_job(body=job_manifest, namespace=settings.KUBE_NAMESPACE) + logging.info("Job created. status='%s'" % str(resp.status)) return HttpResponse(status=status.HTTP_201_CREATED) except ValueError as ve: