Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 6edf099

Browse files
committed
Add AI accelerator device mounting support in CreateControllerContainer
Need this to talk to device via Vulkan, ROCm, etc. Signed-off-by: Eric Curtin <[email protected]>
1 parent a224872 commit 6edf099

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/standalone/containers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"os"
11+
"path/filepath"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -272,6 +273,25 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
272273
hostConfig.DeviceRequests = []container.DeviceRequest{{Count: -1, Capabilities: [][]string{{"gpu"}}}}
273274
}
274275

276+
// Enable access to AI accelerator devices if they exist
277+
devicePaths := []string{"/dev/dri", "/dev/kfd", "/dev/accel", "/dev/davinci*", "/dev/devmm_svm", "/dev/hisi_hdc"}
278+
for _, path := range devicePaths {
279+
devices, err := filepath.Glob(path)
280+
if err != nil {
281+
// Skip on glob error, don't fail container creation
282+
continue
283+
}
284+
for _, device := range devices {
285+
if _, err := os.Stat(device); err == nil {
286+
hostConfig.Devices = append(hostConfig.Devices, container.DeviceMapping{
287+
PathOnHost: device,
288+
PathInContainer: device,
289+
CgroupPermissions: "rwm",
290+
})
291+
}
292+
}
293+
}
294+
275295
// Create the container. If we detect that a concurrent installation is in
276296
// progress (as indicated by a conflicting container name (which should have
277297
// been detected just before installation)), then we'll allow the error to

0 commit comments

Comments
 (0)