mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2026-11-20 07:49:30 +08:00
feat(container): add NVIDIA GPU runtime configuration switch (#14331)
This commit is contained in:
@@ -10,6 +10,9 @@ type DockerStatus struct {
|
||||
}
|
||||
|
||||
type DaemonJsonConf struct {
|
||||
NVIDIA bool `json:"nvidia"`
|
||||
NVIDIASupported bool `json:"nvidiaSupported"`
|
||||
|
||||
IsSwarm bool `json:"isSwarm"`
|
||||
Version string `json:"version"`
|
||||
Mirrors []string `json:"registryMirrors"`
|
||||
|
||||
@@ -8,7 +8,9 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
@@ -213,6 +215,8 @@ func (u *DockerService) LoadDockerConf() (*dto.DaemonJsonConf, error) {
|
||||
if err != nil {
|
||||
return &data, err
|
||||
}
|
||||
defer client.Close()
|
||||
data.NVIDIASupported = client.DaemonHost() == "unix:///var/run/docker.sock"
|
||||
itemVersion, err := client.ServerVersion(ctx)
|
||||
if err == nil {
|
||||
data.Version = itemVersion.Version
|
||||
@@ -226,6 +230,9 @@ func (u *DockerService) LoadDockerConf() (*dto.DaemonJsonConf, error) {
|
||||
if err != nil {
|
||||
return &data, nil
|
||||
}
|
||||
if runtimes, ok := daemonMap["runtimes"].(map[string]interface{}); ok {
|
||||
_, data.NVIDIA = runtimes["nvidia"]
|
||||
}
|
||||
var conf daemonJsonItem
|
||||
arr, err := json.Marshal(daemonMap)
|
||||
if err != nil {
|
||||
@@ -258,6 +265,9 @@ func (u *DockerService) LoadDockerConf() (*dto.DaemonJsonConf, error) {
|
||||
}
|
||||
|
||||
func (u *DockerService) UpdateConf(req dto.SettingUpdate, withRestart bool) error {
|
||||
if req.Key == "NVIDIA" {
|
||||
return updateDockerNVIDIA(req.Value, withRestart)
|
||||
}
|
||||
err := createIfNotExistDaemonJsonFile()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -560,3 +570,200 @@ func validateDockerConfig() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateDockerNVIDIA(value string, withRestart bool) error {
|
||||
if value != "enable" && value != "disable" {
|
||||
return fmt.Errorf("unsupported NVIDIA setting %q", value)
|
||||
}
|
||||
client, err := docker.NewDockerClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Close()
|
||||
if client.DaemonHost() != "unix:///var/run/docker.sock" {
|
||||
return fmt.Errorf("NVIDIA configuration is only supported for the local default Docker socket")
|
||||
}
|
||||
enabled := value == "enable"
|
||||
original, readErr := os.ReadFile(constant.DaemonJsonPath)
|
||||
existed := readErr == nil
|
||||
if readErr != nil && !os.IsNotExist(readErr) {
|
||||
return readErr
|
||||
}
|
||||
daemonMap := make(map[string]interface{})
|
||||
if existed {
|
||||
if err := json.Unmarshal(original, &daemonMap); err != nil {
|
||||
return fmt.Errorf("failed to parse Docker configuration: %w", err)
|
||||
}
|
||||
if daemonMap == nil {
|
||||
return fmt.Errorf("Docker configuration must be a JSON object")
|
||||
}
|
||||
}
|
||||
runtimePath, err := applyDockerNVIDIAConfig(daemonMap, enabled)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if enabled {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
check := checkNVIDIAToolkit(ctx, func(name string) string {
|
||||
if name == "nvidia-container-runtime" {
|
||||
return runtimePath
|
||||
}
|
||||
return findGPUContainerCommand(name)
|
||||
}, func(ctx context.Context, executable string) (string, error) {
|
||||
return cmd.NewCommandMgr(cmd.WithContext(ctx), cmd.WithTimeout(3*time.Second)).RunWithStdout(executable, "--version")
|
||||
})
|
||||
cancel()
|
||||
if check.Status != "passed" {
|
||||
return fmt.Errorf("NVIDIA Container Toolkit is not ready: %s", check.Reason)
|
||||
}
|
||||
}
|
||||
updated, err := json.MarshalIndent(daemonMap, "", "\t")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.MkdirAll(path.Dir(constant.DaemonJsonPath), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := writeDockerNVIDIAConfig(updated); err != nil {
|
||||
return err
|
||||
}
|
||||
restore := func(cause error, restart bool) error {
|
||||
var restoreErr error
|
||||
if existed {
|
||||
restoreErr = writeDockerNVIDIAConfig(original)
|
||||
} else {
|
||||
restoreErr = os.Remove(constant.DaemonJsonPath)
|
||||
}
|
||||
if restoreErr != nil {
|
||||
return fmt.Errorf("%v; failed to restore Docker configuration: %w", cause, restoreErr)
|
||||
}
|
||||
if restart {
|
||||
if err := controller.HandleRestart("docker"); err != nil {
|
||||
return fmt.Errorf("%v; configuration restored but Docker restart failed: %w", cause, err)
|
||||
}
|
||||
}
|
||||
return cause
|
||||
}
|
||||
if global.CACHE != nil {
|
||||
defer global.CACHE.Del(gpuEnvironmentCacheKey)
|
||||
}
|
||||
if err := validateDockerConfig(); err != nil {
|
||||
return restore(err, false)
|
||||
}
|
||||
if !withRestart {
|
||||
return nil
|
||||
}
|
||||
if err := controller.HandleRestart("docker"); err != nil {
|
||||
return restore(fmt.Errorf("failed to restart Docker: %w", err), true)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
info, err := client.Info(ctx)
|
||||
if err != nil {
|
||||
return restore(fmt.Errorf("failed to verify Docker NVIDIA runtime: %w", err), true)
|
||||
}
|
||||
if enabled {
|
||||
check := checkNVIDIADockerConfig(info, readDockerDaemonConfig, findGPUContainerCommand)
|
||||
if check.Status != "passed" {
|
||||
return restore(fmt.Errorf("Docker NVIDIA runtime did not become available: %s", check.Reason), true)
|
||||
}
|
||||
} else if _, registered := info.Runtimes["nvidia"]; registered {
|
||||
return restore(fmt.Errorf("Docker still registers the NVIDIA runtime; check other Docker configuration sources"), true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyDockerNVIDIAConfig(config map[string]interface{}, enabled bool) (string, error) {
|
||||
runtimes, ok := config["runtimes"].(map[string]interface{})
|
||||
if config["runtimes"] != nil && !ok {
|
||||
return "", fmt.Errorf("Docker runtimes configuration must be a JSON object")
|
||||
}
|
||||
if !enabled {
|
||||
delete(runtimes, "nvidia")
|
||||
if len(runtimes) == 0 {
|
||||
delete(config, "runtimes")
|
||||
}
|
||||
if config["default-runtime"] == "nvidia" {
|
||||
delete(config, "default-runtime")
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
if runtimes == nil {
|
||||
runtimes = make(map[string]interface{})
|
||||
config["runtimes"] = runtimes
|
||||
}
|
||||
nvidia, ok := runtimes["nvidia"].(map[string]interface{})
|
||||
if runtimes["nvidia"] != nil && !ok {
|
||||
return "", fmt.Errorf("Docker NVIDIA runtime configuration must be a JSON object")
|
||||
}
|
||||
if nvidia == nil {
|
||||
nvidia = map[string]interface{}{"runtimeArgs": []string{}}
|
||||
runtimes["nvidia"] = nvidia
|
||||
}
|
||||
configured, ok := nvidia["path"].(string)
|
||||
if nvidia["path"] != nil && !ok {
|
||||
return "", fmt.Errorf("Docker NVIDIA runtime path must be a string")
|
||||
}
|
||||
runtimePath := findNVIDIAContainerCommand("nvidia-container-runtime", config)
|
||||
if runtimePath == "" || !cmd.Which(runtimePath) {
|
||||
if configured != "" {
|
||||
return "", fmt.Errorf("configured NVIDIA runtime %q is not executable", configured)
|
||||
}
|
||||
return "", fmt.Errorf("nvidia-container-runtime is not installed or executable")
|
||||
}
|
||||
if configured == "" {
|
||||
nvidia["path"] = runtimePath
|
||||
}
|
||||
return runtimePath, nil
|
||||
}
|
||||
|
||||
func writeDockerNVIDIAConfig(data []byte) error {
|
||||
target := constant.DaemonJsonPath
|
||||
mode := os.FileMode(0640)
|
||||
info, err := os.Lstat(target)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if err == nil {
|
||||
target, err = filepath.EvalSymlinks(target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err = os.Stat(target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.Mode().IsRegular() {
|
||||
return fmt.Errorf("Docker configuration must be a regular file")
|
||||
}
|
||||
mode = info.Mode().Perm()
|
||||
}
|
||||
temp, err := os.CreateTemp(filepath.Dir(target), ".daemon-nvidia-*.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = temp.Close()
|
||||
_ = os.Remove(temp.Name())
|
||||
}()
|
||||
if info != nil {
|
||||
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
|
||||
if err := temp.Chown(int(stat.Uid), int(stat.Gid)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := temp.Chmod(mode); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := temp.Write(data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := temp.Sync(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := temp.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(temp.Name(), target)
|
||||
}
|
||||
|
||||
@@ -226,9 +226,23 @@ func findGPUContainerCommand(name string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func findNVIDIAContainerCommand(name string, config map[string]interface{}) string {
|
||||
if name == "nvidia-container-runtime" {
|
||||
runtimes, _ := config["runtimes"].(map[string]interface{})
|
||||
nvidia, _ := runtimes["nvidia"].(map[string]interface{})
|
||||
if configured, ok := nvidia["path"].(string); ok && configured != "" {
|
||||
name = configured
|
||||
}
|
||||
}
|
||||
return findGPUContainerCommand(name)
|
||||
}
|
||||
|
||||
func checkNVIDIAContainerEnvironment(ctx context.Context) []dto.GPUEnvironmentCheck {
|
||||
config, configErr := readDockerDaemonConfig()
|
||||
toolkitCtx, cancelToolkit := context.WithTimeout(ctx, 5*time.Second)
|
||||
toolkit := checkNVIDIAToolkit(toolkitCtx, findGPUContainerCommand, func(ctx context.Context, path string) (string, error) {
|
||||
toolkit := checkNVIDIAToolkit(toolkitCtx, func(name string) string {
|
||||
return findNVIDIAContainerCommand(name, config)
|
||||
}, func(ctx context.Context, path string) (string, error) {
|
||||
return cmd.NewCommandMgr(cmd.WithContext(ctx), cmd.WithTimeout(3*time.Second)).RunWithStdout(path, "--version")
|
||||
})
|
||||
cancelToolkit()
|
||||
@@ -243,7 +257,7 @@ func checkNVIDIAContainerEnvironment(ctx context.Context) []dto.GPUEnvironmentCh
|
||||
if err == nil {
|
||||
dockerCheck = checkNVIDIADockerInfo(info, false)
|
||||
if cli.DaemonHost() == "unix:///var/run/docker.sock" {
|
||||
dockerCheck = checkNVIDIADockerConfig(info, readDockerDaemonConfig, findGPUContainerCommand)
|
||||
dockerCheck = checkNVIDIADockerConfig(info, func() (map[string]interface{}, error) { return config, configErr }, findGPUContainerCommand)
|
||||
} else {
|
||||
dockerCheck.Status = "unknown"
|
||||
dockerCheck.Reason = "The selected Docker daemon's NVIDIA runtime cannot be verified using local executables or the default daemon.json."
|
||||
|
||||
@@ -416,6 +416,8 @@ export namespace Container {
|
||||
isExist: boolean;
|
||||
}
|
||||
export interface DaemonJsonConf {
|
||||
nvidia: boolean;
|
||||
nvidiaSupported: boolean;
|
||||
isSwarm: boolean;
|
||||
isExist: boolean;
|
||||
isActive: boolean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<DialogPro v-model="submitVisible" :title="header" size="mini">
|
||||
<DialogPro v-model="submitVisible" :title="header" size="mini" @close="onCancel">
|
||||
<div>
|
||||
<span v-if="operationInfo" class="operation-info">{{ operationInfo }}</span>
|
||||
<slot />
|
||||
|
||||
@@ -2350,6 +2350,12 @@ const message = {
|
||||
missing: 'Missing',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU support',
|
||||
nvidiaHelper:
|
||||
'Register the NVIDIA container runtime. Install NVIDIA Container Toolkit first. Assign GPUs to each container separately.',
|
||||
nvidiaLocalOnly: 'Only the local default Docker socket is supported.',
|
||||
nvidiaChangeHelper:
|
||||
'Disabling may prevent containers using the NVIDIA runtime from starting. This switch does not block GPU access.',
|
||||
imageRemoteSearch: 'Remote search',
|
||||
imageRemoteSearchHelper: 'Only Docker Hub repository images can be searched',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2383,6 +2383,12 @@ const message = {
|
||||
missing: 'No existe',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'Compatibilidad con GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Registra el entorno de ejecución de NVIDIA. Instala primero NVIDIA Container Toolkit. Asigna las GPU a cada contenedor por separado.',
|
||||
nvidiaLocalOnly: 'Solo se admite el socket predeterminado de Docker local.',
|
||||
nvidiaChangeHelper:
|
||||
'Al desactivar, los contenedores que usan el entorno de NVIDIA podrían no iniciarse. Este interruptor no bloquea el acceso a la GPU.',
|
||||
imageRemoteSearch: 'Búsqueda remota',
|
||||
imageRemoteSearchHelper: 'Solo se pueden buscar imágenes de repositorios de Docker Hub',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2324,6 +2324,12 @@ const message = {
|
||||
missing: 'ناموجود',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'پشتیبانی از GPU انویدیا',
|
||||
nvidiaHelper:
|
||||
'محیط اجرای کانتینر NVIDIA را ثبت میکند. ابتدا NVIDIA Container Toolkit را نصب کنید. GPU را جداگانه به هر کانتینر اختصاص دهید.',
|
||||
nvidiaLocalOnly: 'فقط سوکت پیشفرض Docker محلی پشتیبانی میشود.',
|
||||
nvidiaChangeHelper:
|
||||
'غیرفعالسازی ممکن است مانع شروع کانتینرهای دارای محیط اجرای NVIDIA شود. این کلید دسترسی به GPU را مسدود نمیکند.',
|
||||
imageRemoteSearch: 'جستجوی راه دور',
|
||||
imageRemoteSearchHelper: 'فقط جستجوی تصاویر مخزن Docker Hub پشتیبانی می\u200cشود',
|
||||
imageRemoteSearchProxyRequired: 'برای جستجوی تصاویر راه دور در محیط فعلی، ابتدا یک سرور پروکسی پیکربندی کنید.',
|
||||
|
||||
@@ -2336,6 +2336,12 @@ const message = {
|
||||
missing: '存在しない',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU サポート',
|
||||
nvidiaHelper:
|
||||
'NVIDIA コンテナーランタイムを登録します。先に NVIDIA Container Toolkit をインストールしてください。GPU はコンテナーごとに割り当てる必要があります。',
|
||||
nvidiaLocalOnly: 'ローカルの既定の Docker ソケットのみ対応しています。',
|
||||
nvidiaChangeHelper:
|
||||
'無効にすると NVIDIA ランタイムを使用するコンテナーが起動できなくなる場合があります。このスイッチは GPU へのアクセスを遮断しません。',
|
||||
imageRemoteSearch: 'リモート検索',
|
||||
imageRemoteSearchHelper: 'Docker Hub リポジトリのイメージのみ検索できます',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2305,6 +2305,12 @@ const message = {
|
||||
missing: '없음',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU 지원',
|
||||
nvidiaHelper:
|
||||
'NVIDIA 컨테이너 런타임을 등록합니다. 먼저 NVIDIA Container Toolkit을 설치하세요. GPU는 각 컨테이너에 별도로 할당해야 합니다.',
|
||||
nvidiaLocalOnly: '로컬 기본 Docker 소켓만 지원합니다.',
|
||||
nvidiaChangeHelper:
|
||||
'비활성화하면 NVIDIA 런타임을 사용하는 컨테이너가 시작되지 않을 수 있습니다. 이 스위치는 GPU 접근을 차단하지 않습니다.',
|
||||
imageRemoteSearch: '원격 검색',
|
||||
imageRemoteSearchHelper: 'Docker Hub 저장소 이미지만 검색할 수 있습니다',
|
||||
imageRemoteSearchProxyRequired: '현재 실행 환경에서 원격 이미지를 검색하려면 먼저 프록시 서버를 설정하세요.',
|
||||
|
||||
@@ -2285,6 +2285,12 @@ const message = {
|
||||
missing: 'ບໍ່ມີ',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'ຮອງຮັບ NVIDIA GPU',
|
||||
nvidiaHelper:
|
||||
'ລົງທະບຽນ NVIDIA runtime ສຳລັບຄອນເທນເນີ. ຕິດຕັ້ງ NVIDIA Container Toolkit ກ່ອນ ແລະ ຈັດສັນ GPU ໃຫ້ແຕ່ລະຄອນເທນເນີແຍກກັນ.',
|
||||
nvidiaLocalOnly: 'ຮອງຮັບສະເພາະ Docker socket ເລີ່ມຕົ້ນໃນເຄື່ອງນີ້.',
|
||||
nvidiaChangeHelper:
|
||||
'ການປິດອາດເຮັດໃຫ້ຄອນເທນເນີທີ່ໃຊ້ NVIDIA runtime ເລີ່ມບໍ່ໄດ້. ສະວິດນີ້ບໍ່ໄດ້ປິດກັ້ນການເຂົ້າໃຊ້ GPU.',
|
||||
imageRemoteSearch: 'ຄົ້ນຫາທາງໄກ',
|
||||
imageRemoteSearchHelper: 'ຮອງຮັບການຄົ້ນຫາອິມເມຈໃນ Docker Hub ເທົ່ານັ້ນ',
|
||||
imageRemoteSearchProxyRequired: 'ເພື່ອຄົ້ນຫາອິມເມຈທາງໄກໃນສະພາບແວດລ້ອມປັດຈຸບັນ ກະລຸນາຕັ້ງຄ່າພຣັອກຊີເຊີບເວີກ່ອນ.',
|
||||
|
||||
@@ -2375,6 +2375,12 @@ const message = {
|
||||
missing: 'Tiada',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'Sokongan GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Daftarkan runtime kontena NVIDIA. Pasang NVIDIA Container Toolkit dahulu. Peruntukkan GPU kepada setiap kontena secara berasingan.',
|
||||
nvidiaLocalOnly: 'Hanya soket Docker lalai setempat disokong.',
|
||||
nvidiaChangeHelper:
|
||||
'Melumpuhkan mungkin menghalang kontena yang menggunakan runtime NVIDIA daripada bermula. Suis ini tidak menyekat akses GPU.',
|
||||
imageRemoteSearch: 'Carian jauh',
|
||||
imageRemoteSearchHelper: 'Hanya imej repositori Docker Hub boleh dicari',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2382,6 +2382,12 @@ const message = {
|
||||
missing: 'Não existe',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'Suporte a GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Registra o runtime de contêiner NVIDIA. Instale primeiro o NVIDIA Container Toolkit. Atribua GPUs a cada contêiner separadamente.',
|
||||
nvidiaLocalOnly: 'Apenas o socket padrão do Docker local é suportado.',
|
||||
nvidiaChangeHelper:
|
||||
'Desativar pode impedir a inicialização de contêineres que usam o runtime NVIDIA. Esta opção não bloqueia o acesso à GPU.',
|
||||
imageRemoteSearch: 'Pesquisa remota',
|
||||
imageRemoteSearchHelper: 'Apenas imagens de repositórios do Docker Hub podem ser pesquisadas',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2373,6 +2373,12 @@ const message = {
|
||||
missing: 'Отсутствует',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'Поддержка GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Регистрирует среду выполнения контейнеров NVIDIA. Сначала установите NVIDIA Container Toolkit. Назначайте GPU каждому контейнеру отдельно.',
|
||||
nvidiaLocalOnly: 'Поддерживается только стандартный локальный сокет Docker.',
|
||||
nvidiaChangeHelper:
|
||||
'Отключение может помешать запуску контейнеров со средой выполнения NVIDIA. Этот переключатель не блокирует доступ к GPU.',
|
||||
imageRemoteSearch: 'Удалённый поиск',
|
||||
imageRemoteSearchHelper: 'Поддерживается поиск образов только в репозиториях Docker Hub',
|
||||
imageRemoteSearchProxyRequired: 'Для поиска удалённых образов в текущей среде сначала настройте прокси-сервер.',
|
||||
|
||||
@@ -2369,6 +2369,12 @@ const message = {
|
||||
missing: 'Mevcut değil',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU desteği',
|
||||
nvidiaHelper:
|
||||
'NVIDIA konteyner çalışma zamanını kaydeder. Önce NVIDIA Container Toolkit kurun. GPU’ları her konteynere ayrı ayrı atayın.',
|
||||
nvidiaLocalOnly: 'Yalnızca yerel varsayılan Docker soketi desteklenir.',
|
||||
nvidiaChangeHelper:
|
||||
'Devre dışı bırakmak NVIDIA çalışma zamanını kullanan konteynerlerin başlamasını engelleyebilir. Bu anahtar GPU erişimini engellemez.',
|
||||
imageRemoteSearch: 'Uzak arama',
|
||||
imageRemoteSearchHelper: 'Yalnızca Docker Hub deposu imajları aranabilir',
|
||||
imageRemoteSearchProxyRequired:
|
||||
|
||||
@@ -2208,6 +2208,10 @@ const message = {
|
||||
missing: '不存在',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU 支援',
|
||||
nvidiaHelper: '註冊 NVIDIA 容器執行環境,需先安裝 NVIDIA Container Toolkit。各容器仍需個別分配 GPU。',
|
||||
nvidiaLocalOnly: '僅支援本機預設 Docker Socket。',
|
||||
nvidiaChangeHelper: '關閉後,使用 NVIDIA 執行環境的容器可能無法啟動;此開關不會禁止容器存取 GPU。',
|
||||
imageRemoteSearch: '遠端搜尋',
|
||||
imageRemoteSearchHelper: '僅支援搜尋 Docker Hub 倉庫映像',
|
||||
imageRemoteSearchProxyRequired: '目前運行環境下,如需搜尋遠端映像,請先設定代理伺服器',
|
||||
|
||||
@@ -2216,6 +2216,10 @@ const message = {
|
||||
missing: '不存在',
|
||||
},
|
||||
container: {
|
||||
nvidiaSupport: 'NVIDIA GPU 支持',
|
||||
nvidiaHelper: '注册 NVIDIA 容器运行时,需要先安装 NVIDIA Container Toolkit。具体容器仍需单独分配 GPU。',
|
||||
nvidiaLocalOnly: '仅支持本机默认 Docker Socket。',
|
||||
nvidiaChangeHelper: '关闭后,使用 NVIDIA 运行时的容器可能无法启动;这不是禁止容器访问 GPU 的安全开关。',
|
||||
imageRemoteSearch: '远程搜索',
|
||||
imageRemoteSearchHelper: '仅支持搜索 Docker Hub 仓库镜像',
|
||||
imageRemoteSearchProxyRequired: '当前运行环境下,如需搜索远程镜像,请优先配置代理服务器',
|
||||
|
||||
@@ -149,6 +149,18 @@
|
||||
<el-switch v-permission v-model="form.iptables" @change="handleIptables"></el-switch>
|
||||
<span class="input-help">{{ $t('container.iptablesHelper1') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.nvidiaSupport')" prop="nvidia">
|
||||
<el-switch
|
||||
v-permission
|
||||
v-model="form.nvidia"
|
||||
:disabled="!form.nvidiaSupported"
|
||||
@change="handleNVIDIA"
|
||||
/>
|
||||
<span class="input-help">{{ $t('container.nvidiaHelper') }}</span>
|
||||
<span v-if="!form.nvidiaSupported" class="input-help">
|
||||
{{ $t('container.nvidiaLocalOnly') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Live restore" prop="liveRestore">
|
||||
<el-switch
|
||||
v-permission
|
||||
@@ -239,6 +251,7 @@
|
||||
<ConfirmDialog ref="confirmDialogRefIpv6" @confirm="onSaveIPv6" @cancel="search" />
|
||||
<ConfirmDialog ref="confirmDialogRefIptable" @confirm="onSubmitOpenIPtable" @cancel="search" />
|
||||
<ConfirmDialog ref="confirmDialogRefLog" @confirm="onSubmitSaveLog" @cancel="search" />
|
||||
<ConfirmDialog ref="confirmDialogRefNVIDIA" @confirm="onSubmitSaveNVIDIA" @cancel="search" />
|
||||
<ConfirmDialog ref="confirmDialogRefLive" @confirm="onSubmitSaveLive" @cancel="search" />
|
||||
<ConfirmDialog ref="confirmDialogRefCgroup" @confirm="onSubmitSaveCgroup" @cancel="search" />
|
||||
|
||||
@@ -288,6 +301,7 @@ const confirmDialogRefLog = ref();
|
||||
const mirrorRef = ref();
|
||||
const registriesRef = ref();
|
||||
const confirmDialogRefLive = ref();
|
||||
const confirmDialogRefNVIDIA = ref();
|
||||
const confirmDialogRefCgroup = ref();
|
||||
const confirmDialogRefIptable = ref();
|
||||
const confirmDialogRefIpv6 = ref();
|
||||
@@ -302,6 +316,8 @@ const form = reactive({
|
||||
mirrors: '',
|
||||
registries: '',
|
||||
liveRestore: false,
|
||||
nvidia: false,
|
||||
nvidiaSupported: false,
|
||||
iptables: true,
|
||||
cgroupDriver: '',
|
||||
|
||||
@@ -407,6 +423,19 @@ const onSubmitOpenIPtable = () => {
|
||||
save('IPtables', 'enable');
|
||||
};
|
||||
|
||||
const handleNVIDIA = () => {
|
||||
confirmDialogRefNVIDIA.value.acceptParams({
|
||||
header: i18n.global.t('database.confChange'),
|
||||
operationInfo: form.nvidia
|
||||
? i18n.global.t('container.restartHelper')
|
||||
: `${i18n.global.t('container.nvidiaChangeHelper')} ${i18n.global.t('container.restartHelper')}`,
|
||||
submitInputInfo: i18n.global.t('database.restartNow'),
|
||||
});
|
||||
};
|
||||
const onSubmitSaveNVIDIA = () => {
|
||||
save('NVIDIA', form.nvidia ? 'enable' : 'disable');
|
||||
};
|
||||
|
||||
const handleLive = async () => {
|
||||
let params = {
|
||||
header: i18n.global.t('database.confChange'),
|
||||
@@ -509,6 +538,8 @@ const search = async () => {
|
||||
form.version = res.data.version;
|
||||
form.cgroupDriver = res.data.cgroupDriver || 'cgroupfs';
|
||||
form.liveRestore = res.data.liveRestore;
|
||||
form.nvidia = res.data.nvidia;
|
||||
form.nvidiaSupported = res.data.nvidiaSupported;
|
||||
form.iptables = res.data.iptables;
|
||||
form.mirrors = res.data.registryMirrors ? res.data.registryMirrors.join('\n') : '';
|
||||
form.registries = res.data.insecureRegistries ? res.data.insecureRegistries.join('\n') : '';
|
||||
|
||||
Reference in New Issue
Block a user