Documentation
¶
Overview ¶
Package cuda finds the processes of a tree that hold CUDA state and moves that state with NVIDIA's cuda-checkpoint: lock, checkpoint to host memory before the CRIU dump; restore onto the receiver's GPUs and unlock after.
Index ¶
- Constants
- func DeviceMap(pairs []Pair) (string, error)
- func Owners(pids []int) ([]int, error)
- type Backend
- type CLI
- func (c *CLI) Checkpoint(ctx context.Context, pid int) error
- func (c *CLI) Lock(ctx context.Context, pid, timeoutMS int) error
- func (c *CLI) Name() string
- func (c *CLI) Restore(ctx context.Context, pid int, pairs []Pair) error
- func (c *CLI) State(ctx context.Context, pid int) (string, error)
- func (c *CLI) Unlock(ctx context.Context, pid int) error
- type Driver
- func (*Driver) Checkpoint(ctx context.Context, pid int) error
- func (*Driver) Lock(ctx context.Context, pid, timeoutMS int) error
- func (*Driver) Name() string
- func (*Driver) Restore(ctx context.Context, pid int, pairs []Pair) error
- func (*Driver) State(ctx context.Context, pid int) (string, error)
- func (*Driver) Unlock(ctx context.Context, pid int) error
- type Pair
- type Session
Constants ¶
const ( BackendAuto = "auto" BackendDriver = "driver" BackendCLI = "cli" )
Backend names: Select takes them, and auto picks the driver when it can.
const ( CallTimeout = 90 * time.Second LockTimeoutMS = 60000 )
CallTimeout bounds one checkpoint call; LockTimeoutMS is how long a lock may wait for in-flight CUDA work.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
Name() string
State(ctx context.Context, pid int) (string, error)
Lock(ctx context.Context, pid, timeoutMS int) error
Checkpoint(ctx context.Context, pid int) error
Restore(ctx context.Context, pid int, pairs []Pair) error
Unlock(ctx context.Context, pid int) error
}
Backend moves the CUDA state of one process. Session keeps the order of the processes, the barriers between phases and the state checks.
type CLI ¶
type CLI struct {
Helper string
// contains filtered or unexported fields
}
CLI runs NVIDIA's cuda-checkpoint once per process and call.
func (*CLI) Checkpoint ¶
Checkpoint moves the locked process's device memory to host memory.
func (*CLI) Lock ¶
Lock blocks the process's CUDA calls, waiting up to timeoutMS for work in flight.
func (*CLI) Restore ¶
Restore puts the checkpointed process's memory back, on the pairs' target GPUs.
type Driver ¶
type Driver struct{}
Driver calls the CUDA checkpoint API of libcuda in this process.
func NewDriver ¶
NewDriver loads libcuda and checks that its restore arguments have a layout known here.
func (*Driver) Checkpoint ¶
Checkpoint moves the locked process's device memory to host memory.
func (*Driver) Lock ¶
Lock blocks the process's CUDA calls, waiting up to timeoutMS for work in flight.
func (*Driver) Restore ¶
Restore puts the checkpointed process's memory back, on the pairs' target GPUs.
type Pair ¶
Pair maps a donor GPU to a receiver GPU.
func ParseDeviceMap ¶
ParseDeviceMap is DeviceMap's inverse.
type Session ¶
type Session struct {
Backend Backend
Owners []int
// Parallel owners are restored concurrently, after the others: the
// workers, when no collective keeps peer memory mapped between them.
Parallel []int
// Concurrent also restores the other owners concurrently, as their own
// barrier before the parallel ones, and unlocks every owner at once.
Concurrent bool
// Phases holds the seconds each phase of the last Restore took.
Phases map[string]float64
}
Session moves the CUDA state of a set of processes through a Backend. Each phase is a barrier: every owner finishes it before any starts the next. A failure is final; the caller removes the container.
func NewSession ¶
NewSession moves the owners' state through b.
func (*Session) Checkpoint ¶
Checkpoint locks every owner and moves its device memory to the host.