mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
Add mount devices to API. (#69)
* add room devices to API. * devicese one 1:1 mapping. * add devices to gui. * get used devices. * rename gpu support to nvidia gpu.
This commit is contained in:
@@ -354,6 +354,11 @@ components:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
example: all
|
example: all
|
||||||
|
devices:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
example: /dev/dri/renderD128
|
||||||
|
|
||||||
RoomSettings:
|
RoomSettings:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -375,6 +375,12 @@ export interface RoomResources {
|
|||||||
* @memberof RoomResources
|
* @memberof RoomResources
|
||||||
*/
|
*/
|
||||||
'gpus'?: Array<string>;
|
'gpus'?: Array<string>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {Array<string>}
|
||||||
|
* @memberof RoomResources
|
||||||
|
*/
|
||||||
|
'devices'?: Array<string>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
<tr><th> CPU Shares </th><td :title="settings.resources.cpu_shares"><span v-if="settings.resources.cpu_shares">{{ settings.resources.cpu_shares }}</span><i v-else>--undefined--</i></td></tr>
|
<tr><th> CPU Shares </th><td :title="settings.resources.cpu_shares"><span v-if="settings.resources.cpu_shares">{{ settings.resources.cpu_shares }}</span><i v-else>--undefined--</i></td></tr>
|
||||||
<tr><th> Shared memory </th><td :title="settings.resources.shm_size">{{ settings.resources.shm_size | memory }}</td></tr>
|
<tr><th> Shared memory </th><td :title="settings.resources.shm_size">{{ settings.resources.shm_size | memory }}</td></tr>
|
||||||
<tr><th> GPUs </th><td><span v-if="settings.resources.gpus && settings.resources.gpus.length > 0">{{ settings.resources.gpus.join(",") }}</span><i v-else>--not used--</i></td></tr>
|
<tr><th> GPUs </th><td><span v-if="settings.resources.gpus && settings.resources.gpus.length > 0">{{ settings.resources.gpus.join(",") }}</span><i v-else>--not used--</i></td></tr>
|
||||||
|
<tr><th> Devices </th><td><span v-if="settings.resources.devices && settings.resources.devices.length > 0">{{ settings.resources.devices.join(",") }}</span><i v-else>--none--</i></td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</template>
|
</template>
|
||||||
</v-simple-table>
|
</v-simple-table>
|
||||||
|
|||||||
@@ -351,6 +351,7 @@
|
|||||||
:max="20*1e9"
|
:max="20*1e9"
|
||||||
:step="0.2*1e9"
|
:step="0.2*1e9"
|
||||||
color="blue"
|
color="blue"
|
||||||
|
hide-details
|
||||||
>
|
>
|
||||||
<template v-slot:thumb-label="{ value }">
|
<template v-slot:thumb-label="{ value }">
|
||||||
<span v-if="value">{{ value | memory }}</span>
|
<span v-if="value">{{ value | memory }}</span>
|
||||||
@@ -361,9 +362,40 @@
|
|||||||
<v-col>
|
<v-col>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
@change="$set(data.resources, 'gpus', $event ? ['all'] : [])"
|
@change="$set(data.resources, 'gpus', $event ? ['all'] : [])"
|
||||||
label="Enable GPU support"
|
label="Enable Nvidia GPU support"
|
||||||
|
hide-details
|
||||||
class="shrink ml-2 mt-0"
|
class="shrink ml-2 mt-0"
|
||||||
></v-checkbox>
|
></v-checkbox>
|
||||||
|
<div style="margin-left: 41px;"><i>Nvidia docker runtime is required.</i></div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row align="center">
|
||||||
|
<v-col class="pt-0">
|
||||||
|
<v-combobox class="pt-0"
|
||||||
|
label="Devices"
|
||||||
|
v-model="data.resources.devices"
|
||||||
|
:items="[ '/dev/dri/renderD128' ]"
|
||||||
|
multiple
|
||||||
|
>
|
||||||
|
<template v-slot:selection="{ attrs, item, parent, selected }">
|
||||||
|
<v-chip
|
||||||
|
v-bind="attrs"
|
||||||
|
:input-value="selected"
|
||||||
|
label
|
||||||
|
small
|
||||||
|
>
|
||||||
|
<span class="pr-2">
|
||||||
|
{{ item }}
|
||||||
|
</span>
|
||||||
|
<v-icon
|
||||||
|
small
|
||||||
|
@click="parent.selectItem(item)"
|
||||||
|
>
|
||||||
|
$delete
|
||||||
|
</v-icon>
|
||||||
|
</v-chip>
|
||||||
|
</template>
|
||||||
|
</v-combobox>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ export const state = {
|
|||||||
memory: 0,
|
memory: 0,
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
shm_size: 2000000000,
|
shm_size: 2000000000,
|
||||||
|
devices: [],
|
||||||
},
|
},
|
||||||
} as RoomSettings,
|
} as RoomSettings,
|
||||||
videoCodecs: [
|
videoCodecs: [
|
||||||
|
|||||||
@@ -401,6 +401,19 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
|
|||||||
deviceRequests = append(deviceRequests, gpuOpts.Value()...)
|
deviceRequests = append(deviceRequests, gpuOpts.Value()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set container devices
|
||||||
|
//
|
||||||
|
|
||||||
|
var devices []container.DeviceMapping
|
||||||
|
for _, device := range settings.Resources.Devices {
|
||||||
|
devices = append(devices, container.DeviceMapping{
|
||||||
|
PathOnHost: device,
|
||||||
|
PathInContainer: device,
|
||||||
|
CgroupPermissions: "rwm",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set container configs
|
// Set container configs
|
||||||
//
|
//
|
||||||
@@ -447,6 +460,7 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
|
|||||||
NanoCPUs: settings.Resources.NanoCPUs,
|
NanoCPUs: settings.Resources.NanoCPUs,
|
||||||
Memory: settings.Resources.Memory,
|
Memory: settings.Resources.Memory,
|
||||||
DeviceRequests: deviceRequests,
|
DeviceRequests: deviceRequests,
|
||||||
|
Devices: devices,
|
||||||
},
|
},
|
||||||
// Privileged
|
// Privileged
|
||||||
Privileged: isPrivilegedImage,
|
Privileged: isPrivilegedImage,
|
||||||
@@ -610,12 +624,23 @@ func (manager *RoomManagerCtx) GetSettings(id string) (*types.RoomSettings, erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devices := []string{}
|
||||||
|
for _, dev := range container.HostConfig.Devices {
|
||||||
|
// TODO: dev.CgroupPermissions
|
||||||
|
if dev.PathOnHost == dev.PathInContainer {
|
||||||
|
devices = append(devices, dev.PathOnHost)
|
||||||
|
} else {
|
||||||
|
devices = append(devices, fmt.Sprintf("%s:%s", dev.PathOnHost, dev.PathInContainer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
roomResources = types.RoomResources{
|
roomResources = types.RoomResources{
|
||||||
CPUShares: container.HostConfig.CPUShares,
|
CPUShares: container.HostConfig.CPUShares,
|
||||||
NanoCPUs: container.HostConfig.NanoCPUs,
|
NanoCPUs: container.HostConfig.NanoCPUs,
|
||||||
ShmSize: container.HostConfig.ShmSize,
|
ShmSize: container.HostConfig.ShmSize,
|
||||||
Memory: container.HostConfig.Memory,
|
Memory: container.HostConfig.Memory,
|
||||||
Gpus: gpus,
|
Gpus: gpus,
|
||||||
|
Devices: devices,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ type RoomResources struct {
|
|||||||
ShmSize int64 `json:"shm_size"` // in bytes
|
ShmSize int64 `json:"shm_size"` // in bytes
|
||||||
Memory int64 `json:"memory"` // in bytes
|
Memory int64 `json:"memory"` // in bytes
|
||||||
Gpus []string `json:"gpus"` // gpu opts
|
Gpus []string `json:"gpus"` // gpu opts
|
||||||
|
Devices []string `json:"devices"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RoomSettings struct {
|
type RoomSettings struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user