diff --git a/paddlecloud/paddlejob/views.py b/paddlecloud/paddlejob/views.py index de3f27a6..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 += 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: