Skip to content

Commit

Permalink
Move GPU resource specification to pod hook
Browse files Browse the repository at this point in the history
This is in the context of providing a dynamic mechanism to check
whether a GPU user is a participant of a SWAN event, and if so
allocate their session on a certain subset of resources with a
configured GPU flavor.

With this move, the configuration of the GPU resource requests
and limits is done in the modify pod hook. This brings some
benefits: we will not need anymore to erase the value of the last
resource specification that was done; we can have GPU treatment
together with the rest of the computing resources; all the GPU
logic can be found in one place.
  • Loading branch information
etejedor committed Apr 24, 2024
1 parent 0997d9b commit 3b77461
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions SwanSpawner/swanspawner/swankubespawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ async def start(self):
"""Perform extra configurations required for SWAN session spawning in
kubernetes.
"""

if self._gpu_requested():
self.extra_resource_guarantees["nvidia.com/gpu"] = "1"
self.extra_resource_limits["nvidia.com/gpu"] = "1"
elif "nvidia.com/gpu" in self.extra_resource_guarantees:
del self.extra_resource_guarantees["nvidia.com/gpu"]
del self.extra_resource_limits["nvidia.com/gpu"]

# Resource requests and limits for user pods

# CPU limit is set to what the user selects in the form
# The request (guarantee) is statically set in the chart;
# the resulting overcommit is acceptable since users stay idle
Expand Down Expand Up @@ -104,14 +94,14 @@ def get_env(self):
""" Set base environmental variables for swan jupyter docker image """
env = super().get_env()

if self._gpu_requested():
if self.gpu_requested():
env.update(dict(
# Configure OpenCL to use NVIDIA backend
OCL_ICD_FILENAMES = 'libnvidia-opencl.so.1',
))

return env

def _gpu_requested(self):
def gpu_requested(self):
"""Returns true if the user requested a GPU"""
return "cu" in self.user_options[self.lcg_rel_field]

0 comments on commit 3b77461

Please sign in to comment.