Skip to content

Commit b46f15c

Browse files
committed
MPS feature
Signed-off-by: Mike McKiernan <[email protected]>
1 parent 351299e commit b46f15c

10 files changed

+643
-14
lines changed

gpu-operator/gpu-sharing-mps.rst

Lines changed: 512 additions & 0 deletions
Large diffs are not rendered by default.

gpu-operator/gpu-sharing.rst

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,35 @@ and not modify nodes with other GPU models.
5454
You can combine the two approaches by applying a cluster-wide default configuration
5555
and then label nodes so that those nodes receive a node-specific configuration.
5656

57-
Comparison: Time-Slicing and Multi-Instance GPU
58-
===============================================
57+
.. _comparison-ts-mps-mig:
5958

60-
The latest generations of NVIDIA GPUs provide an operation mode called
61-
Multi-Instance GPU (MIG). MIG allows you to partition a GPU
62-
into several smaller, predefined instances, each of which looks like a
59+
Comparison: Time-Slicing, Multi-Process Service, and Multi-Instance GPU
60+
=======================================================================
61+
62+
Each of the technologies, time-slicing, Multi-Process Service (MPS), and Multi-Instance GPU (MIG)
63+
enable sharing a physical GPU with more than one workload.
64+
65+
NVIDIA A100 and newer GPUs provide an operation mode called MIG.
66+
MIG enables you to partition a GPU into *slices*.
67+
A slice is a smaller, predefined GPU instance that looks like a
6368
mini-GPU that provides memory and fault isolation at the hardware layer.
6469
You can share access to a GPU by running workloads on one of
6570
these predefined instances instead of the full native GPU.
6671

6772
MIG support was added to Kubernetes in 2020. Refer to `Supporting MIG in Kubernetes <https://www.google.com/url?q=https://docs.google.com/document/d/1mdgMQ8g7WmaI_XVVRrCvHPFPOMCm5LQD5JefgAh6N8g/edit&sa=D&source=editors&ust=1655578433019961&usg=AOvVaw1F-OezvM-Svwr1lLsdQmu3>`_
6873
for details on how this works.
6974

70-
Time-slicing trades the memory and fault-isolation that is provided by MIG
71-
for the ability to share a GPU by a larger number of users.
75+
NVIDIA V100 and newer GPUs support MPS.
76+
MPS enables dividing a physical GPU into *replicas* and assigning workloads to a replica.
77+
While MIG provides fault isolation in hardware, MPS uses software to divide the GPU into replicas.
78+
Each replica receives an equal portion of memory and thread percentage.
79+
For example, if you configure two replicas, each replica has access to 50% of GPU memory and 50% of compute capacity.
80+
81+
Time-slicing is available with all GPUs supported by the Operator.
82+
Unlike MIG, time-slicing has no special memory or fault-isolation.
83+
Like MPS, time-slicing uses the term *replica*, however, the GPU is not divided between workloads.
84+
The GPU performs a context switch and swaps resources on and off the GPU when a workload is scheduled.
85+
7286
Time-slicing also provides a way to provide shared access to a GPU for
7387
older generation GPUs that do not support MIG.
7488
However, you can combine MIG and time-slicing to provide shared access to
@@ -234,15 +248,15 @@ The following table describes the key fields in the config map.
234248
Applying One Cluster-Wide Configuration
235249
=======================================
236250

237-
Perform the following steps to configure GPU time-slicing if you already installed the GPU operator
251+
Perform the following steps to configure GPU time-slicing if you already installed the GPU Operator
238252
and want to apply the same time-slicing configuration on all nodes in the cluster.
239253

240254
#. Create a file, such as ``time-slicing-config-all.yaml``, with contents like the following example:
241255

242256
.. literalinclude:: ./manifests/input/time-slicing-config-all.yaml
243257
:language: yaml
244258

245-
#. Add the config map to the same namespace as the GPU operator:
259+
#. Add the config map to the same namespace as the GPU Operator:
246260

247261
.. code-block:: console
248262
@@ -284,7 +298,7 @@ control which configuration is applied to which nodes.
284298
.. literalinclude:: ./manifests/input/time-slicing-config-fine.yaml
285299
:language: yaml
286300

287-
#. Add the config map to the same namespace as the GPU operator:
301+
#. Add the config map to the same namespace as the GPU Operator:
288302

289303
.. code-block:: console
290304
@@ -339,9 +353,9 @@ Configuring Time-Slicing Before Installing the NVIDIA GPU Operator
339353
You can enable time-slicing with the NVIDIA GPU Operator by passing the
340354
``devicePlugin.config.name=<config-map-name>`` parameter during installation.
341355

342-
Perform the following steps to configure time-slicing before installing the operator:
356+
Perform the following steps to configure time-slicing before installing the Operator:
343357

344-
#. Create the namespace for the operator:
358+
#. Create the namespace for the Operator:
345359

346360
.. code-block:: console
347361
@@ -418,15 +432,17 @@ Perform the following steps to verify that the time-slicing configuration is app
418432
* The ``nvidia.com/gpu.count`` label reports the number of physical GPUs in the machine.
419433
* The ``nvidia.com/gpu.product`` label includes a ``-SHARED`` suffix to the product name.
420434
* The ``nvidia.com/gpu.replicas`` label matches the reported capacity.
435+
* The ``nvidia.com/gpu.sharing-strategy`` label is set to ``time-slicing``.
421436

422437
.. code-block:: output
423-
:emphasize-lines: 3,4,5,7
438+
:emphasize-lines: 3-6,8
424439
425440
...
426441
Labels:
427442
nvidia.com/gpu.count=4
428443
nvidia.com/gpu.product=Tesla-T4-SHARED
429444
nvidia.com/gpu.replicas=4
445+
nvidia.com/gpu.sharing-strategy=time-slicing
430446
Capacity:
431447
nvidia.com/gpu: 16
432448
...
@@ -441,15 +457,17 @@ Perform the following steps to verify that the time-slicing configuration is app
441457
* The ``nvidia.com/gpu`` capacity reports ``0``.
442458
* The ``nvidia.com/gpu.shared`` capacity equals the number of physical GPUs multiplied by the
443459
specified number of GPU replicas to create.
460+
* The ``nvidia.com/gpu.sharing-strategy`` label is set to ``time-slicing``.
444461

445462
.. code-block:: output
446-
:emphasize-lines: 3,7,8
463+
:emphasize-lines: 3,8,9
447464
448465
...
449466
Labels:
450467
nvidia.com/gpu.count=4
451468
nvidia.com/gpu.product=Tesla-T4
452469
nvidia.com/gpu.replicas=4
470+
nvidia.com/gpu.sharing-strategy=time-slicing
453471
Capacity:
454472
nvidia.com/gpu: 0
455473
nvidia.com/gpu.shared: 16

gpu-operator/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
:hidden:
4141

4242
Multi-Instance GPU <gpu-operator-mig.rst>
43+
MPS GPU Sharing <gpu-sharing-mps.rst>
4344
Time-Slicing GPUs <gpu-sharing.rst>
4445
gpu-operator-rdma.rst
4546
Outdated Kernels <install-gpu-operator-outdated-kernels.rst>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: mps-config-all
5+
data:
6+
mps-any: |-
7+
version: v1
8+
sharing:
9+
mps:
10+
resources:
11+
- name: nvidia.com/gpu
12+
replicas: 4
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: mps-config-fine
5+
data:
6+
mps-four: |-
7+
version: v1
8+
sharing:
9+
mps:
10+
renameByDefault: false
11+
resources:
12+
- name: nvidia.com/gpu
13+
replicas: 4
14+
mps-two: |-
15+
version: v1
16+
sharing:
17+
mps:
18+
renameByDefault: false
19+
resources:
20+
- name: nvidia.com/gpu
21+
replicas: 2
22+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mps-verification
5+
labels:
6+
app: mps-verification
7+
spec:
8+
replicas: 5
9+
selector:
10+
matchLabels:
11+
app: mps-verification
12+
template:
13+
metadata:
14+
labels:
15+
app: mps-verification
16+
spec:
17+
tolerations:
18+
- key: nvidia.com/gpu
19+
operator: Exists
20+
effect: NoSchedule
21+
hostPID: true
22+
containers:
23+
- name: cuda-sample-vector-add
24+
image: "nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04"
25+
command: ["/bin/bash", "-c", "--"]
26+
args:
27+
- while true; do /cuda-samples/vectorAdd; done
28+
resources:
29+
limits:
30+
nvidia.com/gpu: 1
31+
nodeSelector:
32+
nvidia.com/gpu.sharing-strategy: mps

gpu-operator/manifests/input/time-slicing-verification.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ spec:
2828
resources:
2929
limits:
3030
nvidia.com/gpu: 1
31+
nodeSelector:
32+
nvidia.com/gpu.sharing-strategy: time-slicing
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LAST SEEN TYPE REASON OBJECT MESSAGE
2+
38s Normal SuccessfulDelete daemonset/nvidia-device-plugin-daemonset Deleted pod: nvidia-device-plugin-daemonset-l86fw
3+
38s Normal SuccessfulDelete daemonset/gpu-feature-discovery Deleted pod: gpu-feature-discovery-shj2m
4+
38s Normal Killing pod/gpu-feature-discovery-shj2m Stopping container gpu-feature-discovery
5+
38s Normal Killing pod/nvidia-device-plugin-daemonset-l86fw Stopping container nvidia-device-plugin
6+
37s Normal Scheduled pod/nvidia-device-plugin-daemonset-lcklx Successfully assigned gpu-operator/nvidia-device-plugin-daemonset-lcklx to worker-1
7+
37s Normal SuccessfulCreate daemonset/gpu-feature-discovery Created pod: gpu-feature-discovery-pgx9l
8+
37s Normal Scheduled pod/gpu-feature-discovery-pgx9l Successfully assigned gpu-operator/gpu-feature-discovery-pgx9l to worker-0
9+
37s Normal SuccessfulCreate daemonset/nvidia-device-plugin-daemonset Created pod: nvidia-device-plugin-daemonset-lcklx
10+
36s Normal Created pod/nvidia-device-plugin-daemonset-lcklx Created container config-manager-init
11+
36s Normal Pulled pod/nvidia-device-plugin-daemonset-lcklx Container image "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v24.3.0" already present on machine
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
NAME READY STATUS RESTARTS AGE
2+
mps-verification-86c99b5666-hczcn 1/1 Running 0 3s
3+
mps-verification-86c99b5666-sj8z5 1/1 Running 0 3s
4+
mps-verification-86c99b5666-tnjwx 1/1 Running 0 3s
5+
mps-verification-86c99b5666-82hxj 1/1 Running 0 3s
6+
mps-verification-86c99b5666-9lhh6 1/1 Running 0 3s
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Found 5 pods, using pod/mps-verification-86c99b5666-tnjwx
2+
[Vector addition of 50000 elements]
3+
Copy input data from the host memory to the CUDA device
4+
CUDA kernel launch with 196 blocks of 256 threads
5+
Copy output data from the CUDA device to the host memory
6+
Test PASSED
7+
Done
8+
[Vector addition of 50000 elements]
9+
Copy input data from the host memory to the CUDA device
10+
CUDA kernel launch with 196 blocks of 256 threads
11+
Copy output data from the CUDA device to the host memory
12+
Test PASSED
13+
...

0 commit comments

Comments
 (0)