mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Merge pull request #35597 from feiskyer/gpu
Automatic merge from submit-queue CRI: Add devices to ContainerConfig This PR adds devices to ContainerConfig and adds experimental GPU support. cc/ @yujuhong @Hui-Zhi @vishh @kubernetes/sig-node
This commit is contained in:
@@ -635,7 +635,6 @@ func (dm *DockerManager) runContainer(
|
||||
memoryLimit := container.Resources.Limits.Memory().Value()
|
||||
cpuRequest := container.Resources.Requests.Cpu()
|
||||
cpuLimit := container.Resources.Limits.Cpu()
|
||||
nvidiaGPULimit := container.Resources.Limits.NvidiaGPU()
|
||||
var cpuShares int64
|
||||
// If request is not specified, but limit is, we want request to default to limit.
|
||||
// API server does this for new containers, but we repeat this logic in Kubelet
|
||||
@@ -647,17 +646,18 @@ func (dm *DockerManager) runContainer(
|
||||
// of CPU shares.
|
||||
cpuShares = cm.MilliCPUToShares(cpuRequest.MilliValue())
|
||||
}
|
||||
var devices []dockercontainer.DeviceMapping
|
||||
if nvidiaGPULimit.Value() != 0 {
|
||||
// Experimental. For now, we hardcode /dev/nvidia0 no matter what the user asks for
|
||||
// (we only support one device per node).
|
||||
devices = []dockercontainer.DeviceMapping{
|
||||
{PathOnHost: "/dev/nvidia0", PathInContainer: "/dev/nvidia0", CgroupPermissions: "mrw"},
|
||||
{PathOnHost: "/dev/nvidiactl", PathInContainer: "/dev/nvidiactl", CgroupPermissions: "mrw"},
|
||||
{PathOnHost: "/dev/nvidia-uvm", PathInContainer: "/dev/nvidia-uvm", CgroupPermissions: "mrw"},
|
||||
|
||||
// Set devices for container.
|
||||
devices := make([]dockercontainer.DeviceMapping, len(opts.Devices))
|
||||
for i, device := range opts.Devices {
|
||||
devices[i] = dockercontainer.DeviceMapping{
|
||||
PathOnHost: device.PathOnHost,
|
||||
PathInContainer: device.PathInContainer,
|
||||
CgroupPermissions: device.Permissions,
|
||||
}
|
||||
}
|
||||
binds := makeMountBindings(opts.Mounts)
|
||||
|
||||
// The reason we create and mount the log file in here (not in kubelet) is because
|
||||
// the file's location depends on the ID of the container, and we need to create and
|
||||
// mount the file before actually starting the container.
|
||||
|
||||
Reference in New Issue
Block a user