MPS v3 Namespaces#
A namespace subdivides a server’s resources – pinned memory limit, active thread percentage, client priority, and per-device SM partitions – for a group of clients. Servers are typically shared across many clients with different resource needs; namespaces let those groups of clients be managed independently without requiring a separate server per group.
Every server has an implicit default namespace. Clients are assigned to a namespace
using the routing rules below. Refer to MPS v3 Interface for the
namespace create/delete/list/set/get command reference, and to
MPS v3 Configuration File for configuring namespaces from a TOML file.
Namespace Routing#
A client’s namespace is selected by the socket it connects to and, for the main daemon control socket, by its cgroup or UID:
$CUDA_MPS_PIPE_DIRECTORY/
├── control # main daemon control socket
├── training/ # server "training"
│ ├── control # server listener socket (routes to the default namespace)
│ ├── default/
│ │ └── control # default namespace socket
│ ├── high_priority/ # custom namespace
│ │ └── control # namespace socket
│ └── batch/
│ └── control
$CUDA_MPS_PIPE_DIRECTORY/training/high_priority/control– routes to thehigh_prioritynamespace on servertraining.$CUDA_MPS_PIPE_DIRECTORY/training/control– routes to servertraining’sdefaultnamespace.$CUDA_MPS_PIPE_DIRECTORY/control– cgroup matching first, then UID-based auto-routing if no mapping applies.
A client sets CUDA_MPS_PIPE_DIRECTORY to the namespace’s directory to connect
through that namespace’s socket, in the same way Legacy MPS v2 clients set it to a
server’s pipe directory.
Cgroup Matching#
Starting with driver version r620, MPS v3 supports cgroup matching and routing.
A custom namespace on a named server can be associated with a cgroup v2 subtree when the namespace is created. Clients in that subtree can then connect through the main daemon control socket and be routed to the namespace automatically. Connections through an explicit server or namespace socket keep the routing described above.
$ nvidia-cuda-mps-control server create training
$ nvidia-cuda-mps-control namespace create high_priority --server=training \
--cgroup=/sys/fs/cgroup/training --cgroup-depth=1
$ nvidia-cuda-mps-control namespace get high_priority training cgroup
$ nvidia-cuda-mps-control namespace list high_priority --server=training
--cgroup takes an absolute path below /sys/fs/cgroup. The root itself cannot be
mapped. Omitting the option, or using --cgroup=none, leaves the namespace unmapped.
The same path cannot be assigned to more than one namespace in the daemon, but mappings
for nested paths are allowed. The built-in default namespace cannot have a mapping.
--cgroup-depth limits how many levels below the mapped path a client may match:
Omitted – match the mapped cgroup and all descendants.
0– match only the mapped cgroup.1through64– match the mapped cgroup and descendants up to that depth.
For the example above, /sys/fs/cgroup/training and
/sys/fs/cgroup/training/worker match; /sys/fs/cgroup/training/worker/job does
not. Matching respects path components, so /sys/fs/cgroup/training_other does not
match. If several mappings match within their depth limits, the most specific path wins.
After the workload launcher places a client in the mapped cgroup, launch it with
CUDA_MPS_PIPE_DIRECTORY set to the daemon’s pipe directory. For a daemon using
/run/nvidia-mps:
$ CUDA_MPS_PIPE_DIRECTORY=/run/nvidia-mps ./nbody
Cgroup routing requires the daemon to run in the host PID and cgroup namespaces. If
routing is inactive, the client’s cgroup cannot be resolved, or no mapping matches, the
daemon falls back to the UID server’s default namespace (UID 0 in multiuser mode).
If that server must be created, the existing context-share auto-spawn policy applies.
The cgroup and depth are creation-time settings. To change them, delete and recreate the namespace. Equivalent TOML settings are described in MPS v3 Configuration File.
SM Partition Assignments#
Starting with driver version r620, namespaces support SM partition assignments.
A namespace can assign one SM partition per device to its clients. Create the partition on the same server and device first, using SM Partitions, then assign it by name:
$ nvidia-cuda-mps-control namespace set high_priority --server=training \
--device=GPU-74d43ed3-cdf7-e667-3644-bf5b4f46ed65 --sm-partition=large
$ nvidia-cuda-mps-control namespace get high_priority training sm-partitions
Use server set to assign a partition to the server’s built-in default namespace:
$ nvidia-cuda-mps-control server set training \
--device=GPU-74d43ed3-cdf7-e667-3644-bf5b4f46ed65 --sm-partition=large
This changes only the default namespace; custom namespaces keep their own assignments. In either command, set or clear the SM partition separately from other properties.
For each device, the client’s namespace assignment takes precedence over
CUDA_MPS_SM_PARTITION. If the namespace has no assignment for that device, the
environment variable is used when it contains a matching entry. Otherwise, the client
uses the normal unpartitioned behavior for that device.
Assignments can be configured before the server starts or changed on a running server.
Setting or clearing an assignment is rejected while clients are attached to the target
namespace. After those clients exit, clear an assignment with --sm-partition=none:
$ nvidia-cuda-mps-control namespace set high_priority --server=training \
--device=GPU-74d43ed3-cdf7-e667-3644-bf5b4f46ed65 --sm-partition=none
Clearing restores the environment-variable fallback for that device. An SM partition cannot be deleted while any namespace references it; clear all such assignments first, including any assignment on the default namespace.