-
Notifications
You must be signed in to change notification settings - Fork 5k
Add krunkit driver supporting GPU acceleration on macOS #20826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @nirs. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Can one of the admins verify this patch? |
7cda3a5
to
cbe0012
Compare
@afbjorklund can you review this? I think the issue of not having /dev/dri is using too old kernel. We are using 5.10.207 while libkrun seems to require 5.16 or later. libkrun for macOS is using venus, which requires
So it seems that we need to move to newer kernel. Do you know why are stuck with 5.10?
|
I don't think it is stuck with anything, just that it was using the LTS versions... It seems that a new kernel version was not included, in the minikube OS upgrade. Buildroot supports many: https://github.com/buildroot/buildroot/blob/2025.02.x/linux/linux.hash
See also https://www.kernel.org/ ("longterm") |
So should we try to update the kernel to latest longterm version (6.12.30)? |
There was some talk about bumping to a newer kernel: (6.6?) But that was last year, and for the 2024.02.x OS. So maybe. It seems that it is only needed for this AI feature, though? |
Yes, this is for AI on Apple silicon. I can try to get build an iso to play with it, and when we a working iso we can discuss how to proceed with the upgrade. |
So you could still use vfkit for all other (non-AI) usage of Kubernetes. Or maybe even make it a single driver, if the syntax is close enough... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Rebased on #21089 to consume the new iso. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @nirs just two small minor typos and then we can merge this
krunkit is a tool to launch configurable virtual machines using the libkrun platform, optimized for GPU accelerated virtual machines and AI workloads on Apple silicon. It is mostly compatible with vfkit; the driver is a simplified copy of the vfkit driver. Unlike vfkit, krunkit is available only on Apple silicon. Changes compared to vfkit driver: - krunkit requires unix socket for networking, so we must use vment-helper. - krunkit does not support HardStop, so we kill it using SIGKILL. - We must enable vmnet offloading, required for krunkit. - The code was simplified since vmnet-helper is always used - Code was cleaned up to use .ResolveStorePath() - Unused Upgrade() function was removed - Types and functions that should not be public made private We require krunkit 0.2.2, supporting --restul-uri=unix://.
Previously it was used only for vfkit, so we suggested to fallback to the `nat` network. This advice is not relevant to krunkit or to qemu (which can also use vmnet-helper). Change the error to recommend installing vment-helper. We need to think how we can recommend other networks for vfkit and qemu. Another solution is to create error for every driver+network combination but this seems hard to manage.
This is the same way that we test vfkit. This test is not running in the CI. Issues: - Need to install and configure vment-helper (requires root).
Fixed |
Testing krunkit with unsupported platform$ out/minikube start --driver krunkit
😄 minikube v1.36.0 on Fedora 42 (kvm/amd64)
❌ Exiting due to DRV_UNSUPPORTED_OS: The driver 'krunkit' is not supported on linux/amd64 Testing krunkit not installed% out/minikube start --driver krunkit
😄 minikube v1.36.0 on Darwin 15.5 (arm64)
✨ Using the krunkit (experimental) driver based on user configuration
🤷 Exiting due to PROVIDER_KRUNKIT_NOT_FOUND: The 'krunkit' provider was not found: exec: "krunkit": executable file not found in $PATH
💡 Suggestion: Run 'brew tap slp/krunkit && brew install krunkit'
📘 Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/krunkit/ Testing vmnet-helper not installed% out/minikube start --driver krunkit
😄 minikube v1.36.0 on Darwin 15.5 (arm64)
✨ Using the krunkit (experimental) driver based on user configuration
🤷 Exiting due to PROVIDER_KRUNKIT_NOT_FOUND: The 'krunkit' provider was not found: stat /opt/vmnet-helper/bin/vmnet-helper: no such file or directory
💡 Suggestion: Install and configure vment-helper
📘 Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/krunkit/ Testing vment-helper not configuredsudores rule not installed, password required during startup. % out/minikube start --driver krunkit
😄 minikube v1.36.0 on Darwin 15.5 (arm64)
💡 Unable to run vmnet-helper without a password
To configure vment-helper to run without a password, please check the documentation:
https://github.com/nirs/vmnet-helper/#granting-permission-to-run-vmnet-helper
Password:
✨ Using the krunkit (experimental) driver based on user configuration
👍 Starting "minikube" primary control-plane node in "minikube" cluster
🔥 Creating krunkit VM (CPUs=2, Memory=6144MB, Disk=20000MB) ...
🐳 Preparing Kubernetes v1.33.2 on Docker 28.3.2 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default Testing vment-helper configuredUsing passwordless sudo. % sudo --reset-timestamp
% out/minikube start --driver krunkit
😄 minikube v1.36.0 on Darwin 15.5 (arm64)
✨ Using the krunkit (experimental) driver based on user configuration
👍 Starting "minikube" primary control-plane node in "minikube" cluster
🔥 Creating krunkit VM (CPUs=2, Memory=6144MB, Disk=20000MB) ...
🐳 Preparing Kubernetes v1.33.2 on Docker 28.3.2 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default |
kvm2 driver with docker runtime
Times for minikube start: 48.7s 52.6s 50.3s 48.1s 46.7s Times for minikube (PR 20826) ingress: 14.9s 15.9s 14.9s 14.9s 13.9s docker driver with docker runtime
Times for minikube start: 21.2s 22.3s 22.8s 22.5s 24.6s Times for minikube ingress: 12.7s 12.2s 12.7s 13.2s 13.3s docker driver with containerd runtime
Times for minikube start: 20.5s 24.4s 21.8s 24.9s 20.2s Times for minikube ingress: 22.7s 38.7s 22.7s 22.7s 23.2s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @nirs this is gonna be the highlight of the next release and enables developing AI/ML on kubernetes macbook machines !
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: medyagh, nirs The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
krunkit is a tool to launch configurable virtual machines using the libkrun platform, optimized for GPU accelerated virtual machines and AI workloads on Apple silicon.
It is mostly compatible with vfkit; the driver is a simplified copy of the vfkit driver.
To experiment with the krunkit driver see https://github.com/medyagh/ai-playground-minikube/tree/main/macos
Benchmarking GPU compute workloads shows 2 orders of magnitude improvement with Virtio-GPU, and fully utilized GPU:
Status
Integration test results
Created with iso from #21089 using:
krunkit.tar.gz
Fixes #20803