mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
gpu_acceleration flag & nvidia hacking
This commit is contained in:
6
NVIDIA.md
Normal file
6
NVIDIA.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
install:
|
||||||
|
dkms
|
||||||
|
linux-headers-$(uname-r)
|
||||||
|
|
||||||
|
then run:
|
||||||
|
https://us.download.nvidia.com/XFree86/aarch64/580.119.02/NVIDIA-Linux-aarch64-580.119.02.run
|
||||||
0
build/README.md
Normal file
0
build/README.md
Normal file
@@ -5,7 +5,3 @@
|
|||||||
+ firmware-libertas
|
+ firmware-libertas
|
||||||
+ firmware-misc-nonfree
|
+ firmware-misc-nonfree
|
||||||
+ firmware-realtek
|
+ firmware-realtek
|
||||||
+ libnvidia-container-tools
|
|
||||||
+ libnvidia-container1
|
|
||||||
+ nvidia-container-toolkit
|
|
||||||
+ nvidia-driver
|
|
||||||
20
core/src/lxc/gpu_config
Normal file
20
core/src/lxc/gpu_config
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
# NVIDIA Devices Spe
|
||||||
|
lxc.cgroup2.devices.allow: c 235:* rwm
|
||||||
|
|
||||||
|
# DRM devices
|
||||||
|
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=di
|
||||||
|
|
||||||
|
# Device IDs for /dev/dri, check `ls -l /dev/dri`
|
||||||
|
lxc.cgroup2.devices.allow: c 226:* rwm
|
||||||
|
|
||||||
|
# Nvidia nodes
|
||||||
|
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
|
||||||
|
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
|
||||||
|
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
|
||||||
|
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
|
||||||
|
|
||||||
|
# Device IDs for /dev/nvidia*, check `ls -l /dev/nvidia*`
|
||||||
|
lxc.cgroup2.devices.allow: c 195:* rwm
|
||||||
|
lxc.cgroup2.devices.allow: c 500:* rwm
|
||||||
|
lxc.cgroup2.devices.allow: c 503:* rwm
|
||||||
@@ -174,11 +174,11 @@ impl LxcContainer {
|
|||||||
let machine_id = hex::encode(rand::random::<[u8; 16]>());
|
let machine_id = hex::encode(rand::random::<[u8; 16]>());
|
||||||
let container_dir = Path::new(LXC_CONTAINER_DIR).join(&*guid);
|
let container_dir = Path::new(LXC_CONTAINER_DIR).join(&*guid);
|
||||||
tokio::fs::create_dir_all(&container_dir).await?;
|
tokio::fs::create_dir_all(&container_dir).await?;
|
||||||
tokio::fs::write(
|
let mut config_str = format!(include_str!("./config.template"), guid = &*guid);
|
||||||
container_dir.join("config"),
|
if config.gpu_acceleration {
|
||||||
format!(include_str!("./config.template"), guid = &*guid),
|
config_str += include_str!("./gpu_config");
|
||||||
)
|
}
|
||||||
.await?;
|
tokio::fs::write(container_dir.join("config"), config_str).await?;
|
||||||
// TODO: append config
|
// TODO: append config
|
||||||
let rootfs_dir = container_dir.join("rootfs");
|
let rootfs_dir = container_dir.join("rootfs");
|
||||||
let rootfs = OverlayGuard::mount(
|
let rootfs = OverlayGuard::mount(
|
||||||
@@ -414,7 +414,10 @@ impl Drop for LxcContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Serialize)]
|
#[derive(Default, Serialize)]
|
||||||
pub struct LxcConfig {}
|
pub struct LxcConfig {
|
||||||
|
pub gpu_acceleration: bool,
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn connect(ctx: &RpcContext, container: &LxcContainer) -> Result<Guid, Error> {
|
pub async fn connect(ctx: &RpcContext, container: &LxcContainer) -> Result<Guid, Error> {
|
||||||
use axum::extract::ws::Message;
|
use axum::extract::ws::Message;
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,10 @@ impl TryFrom<ManifestV1> for Manifest {
|
|||||||
git_hash: value.git_hash,
|
git_hash: value.git_hash,
|
||||||
os_version: value.eos_version,
|
os_version: value.eos_version,
|
||||||
sdk_version: None,
|
sdk_version: None,
|
||||||
|
gpu_acceleration: match value.main {
|
||||||
|
PackageProcedure::Docker(d) => d.gpu_acceleration,
|
||||||
|
PackageProcedure::Script(_) => false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ pub struct Manifest {
|
|||||||
pub dependencies: Dependencies,
|
pub dependencies: Dependencies,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hardware_requirements: HardwareRequirements,
|
pub hardware_requirements: HardwareRequirements,
|
||||||
|
#[serde(default)]
|
||||||
|
pub gpu_acceleration: bool,
|
||||||
pub git_hash: Option<GitHash>,
|
pub git_hash: Option<GitHash>,
|
||||||
#[serde(default = "current_version")]
|
#[serde(default = "current_version")]
|
||||||
#[ts(type = "string")]
|
#[ts(type = "string")]
|
||||||
|
|||||||
@@ -96,7 +96,9 @@ impl PersistentContainer {
|
|||||||
.join("logs")
|
.join("logs")
|
||||||
.join(&s9pk.as_manifest().id),
|
.join(&s9pk.as_manifest().id),
|
||||||
),
|
),
|
||||||
LxcConfig::default(),
|
LxcConfig {
|
||||||
|
gpu_acceleration: s9pk.manifest.gpu_acceleration,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let rpc_client = lxc_container.connect_rpc(Some(RPC_CONNECT_TIMEOUT)).await?;
|
let rpc_client = lxc_container.connect_rpc(Some(RPC_CONNECT_TIMEOUT)).await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user