From 2b566673de66f1e006b4128f10c63ac933327869 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Tue, 22 Aug 2017 18:53:51 +0800 Subject: [PATCH 1/2] fix bug --- paddlecloud/paddlejob/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddlecloud/paddlejob/views.py b/paddlecloud/paddlejob/views.py index de3f27a6..56e9e311 100644 --- a/paddlecloud/paddlejob/views.py +++ b/paddlecloud/paddlejob/views.py @@ -115,7 +115,7 @@ def post(self, request, format=None): # only statistics trainer GPU resource, pserver does not use GPU if 'paddle-job' in pod.metadata.labels and \ pod.status.phase == 'Running': - gpu_usage += pod.spec.containers[0].resources.limits['alpha.kubernetes.io/nvidia-gpu'] + gpu_usage += int(pod.spec.containers[0].resources.limits['alpha.kubernetes.io/nvidia-gpu']) if username in settings.GPU_QUOTA: gpu_quota = settings.GPU_QUOTA[username]['limit'] else: From 8798039a0a42450714139315e97c071e2da8191c Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Wed, 23 Aug 2017 09:32:23 +0800 Subject: [PATCH 2/2] update --- paddlecloud/paddlejob/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddlecloud/paddlejob/views.py b/paddlecloud/paddlejob/views.py index 56e9e311..8357f1c3 100644 --- a/paddlecloud/paddlejob/views.py +++ b/paddlecloud/paddlejob/views.py @@ -115,7 +115,7 @@ def post(self, request, format=None): # only statistics trainer GPU resource, pserver does not use GPU if 'paddle-job' in pod.metadata.labels and \ pod.status.phase == 'Running': - gpu_usage += int(pod.spec.containers[0].resources.limits['alpha.kubernetes.io/nvidia-gpu']) + gpu_usage += int(pod.spec.containers[0].resources.limits.get('alpha.kubernetes.io/nvidia-gpu', '0')) if username in settings.GPU_QUOTA: gpu_quota = settings.GPU_QUOTA[username]['limit'] else: