From ebed6462f6450214efa433927357f21ebc10161b Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Tue, 8 Oct 2024 17:29:29 +0200 Subject: [PATCH] feat(krz01): introduce ML01 -- a machine learning VM I will add ollama on it later on and passthrough the GPU in there. Signed-off-by: Ryan Lahfa --- machines/krz01/_configuration.nix | 5 +++++ machines/krz01/microvm-ml01.nix | 22 ++++++++++++++++++++++ machines/krz01/nvidia-tesla-k80.nix | 5 ++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 machines/krz01/microvm-ml01.nix diff --git a/machines/krz01/_configuration.nix b/machines/krz01/_configuration.nix index f63a9a1..154edfe 100644 --- a/machines/krz01/_configuration.nix +++ b/machines/krz01/_configuration.nix @@ -10,6 +10,8 @@ lib.extra.mkConfig { "microvm-router01" "nvidia-tesla-k80" "proxmox" + # Machine learning API machine + "microvm-ml01" ]; extraConfig = { @@ -24,6 +26,9 @@ lib.extra.mkConfig { services.netbird.enable = true; + # We are going to use CUDA here. + nixpkgs.config.cudaSupport = true; + users.users.root.hashedPassword = "$y$j9T$eNZQgDN.J5y7KTG2hXgat1$J1i5tjx5dnSZu.C9B7swXi5zMFIkUnmRrnmyLHFAt8/"; }; diff --git a/machines/krz01/microvm-ml01.nix b/machines/krz01/microvm-ml01.nix new file mode 100644 index 0000000..5980524 --- /dev/null +++ b/machines/krz01/microvm-ml01.nix @@ -0,0 +1,22 @@ +_: { + microvm.autostart = [ "ml01" ]; + microvm.vms.ml01 = { + config = { + networking.hostName = "ml01"; + services.ollama = { + enable = true; + listenAddress = "0.0.0.0:11434"; + sandbox = true; + acceleration = "cuda"; + }; + microvm.shares = [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "ro-store"; + proto = "virtiofs"; + } + ]; + }; + }; +} diff --git a/machines/krz01/nvidia-tesla-k80.nix b/machines/krz01/nvidia-tesla-k80.nix index 2828369..3d7f6ba 100644 --- a/machines/krz01/nvidia-tesla-k80.nix +++ b/machines/krz01/nvidia-tesla-k80.nix @@ -1,5 +1,8 @@ { config, ... }: { + nixpkgs.config.nvidia.acceptLicense = true; # Tesla K80 is not supported by the latest driver. - hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages_legacy_470; + hardware.nvidia.package = config.boot.kernelPackages.nvidia_x11_legacy470; + # Don't ask. + services.xserver.videoDrivers = [ "nvidia" ]; }