gpu-cuda
ما الذي تفعله
توضح هذه المهارة كيفية السماح لبرنامج داخل جهاز smolvm افتراضي باستخدام بطاقة NVIDIA على حاسوبك، والتحقق من أنها تعمل فعلًا. وهي لمن يشغّل أعمالًا كثيفة على معالج الرسوميات داخل بيئة معزولة.
متى تستخدمها
- ✓عندما يحتاج برنامج داخل جهاز إلى بطاقة رسوميات ليعمل أسرع.
- ✓عندما يكون nvidia-smi أو جهاز GPU مفقودًا داخل الجهاز.
- ✓عندما ينتهي برنامج CUDA دون أخطاء لكنه قد لا يستخدم وحدة المعالجة الرسومية أصلًا.
رابط المهارة
https://github.com/smol-machines/smolvm/blob/main/docs/gpu-cuda/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“برنامج CUDA الخاص بي يعمل داخل جهاز smolvm، لكن nvidia-smi مفقود. كيف أشغّل وحدة معالجة الرسوميات؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يصل الجهاز إلى بطاقة NVIDIA لدى المضيف عبر مسار بعيد، مع إضافة مكتبة توافق داخله. ثم تشغّل المهارة فحوصات تُظهر أن البيانات تصل فعلًا إلى وحدة المعالجة الرسومية.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
CUDA inside a machine
Verified on smolvm v1.22.2 against an NVIDIA GeForce RTX 4050 (driver 32.0.15.6626, Windows x86_64), 2026-10-03, and on v1.14.6 against an NVIDIA A10 (driver 580.105.08, Linux x86_64, kernel 6.8.0-1046-nvidia). Done means a program in the VM opens the device, creates a context, and moves data to and from it. The Linux runs used the scripts of their date; this version's preflight and cleanup scripts ran on Linux aarch64 on v1.22.2 on 2026-10-03.
The GPU path was last run end to end on Linux x86_64 on v1.14.6, on an A10: the preflight, the probe against two glibc images, all three eval prompts and the cleanup. Windows was re-run on v1.22.2 against an RTX 4050: the probe, the two absences, the shim in a plain
alpineguest, and a vector add over 16777216 elements; seereferences/windows.md. The macOS arm64 and Linux aarch64 hosts have no NVIDIA hardware, so what runs there is the no-GPU answer, on v1.22.2 on macOS and v1.18.2 on Linux aarch64: the preflight reportsgpu_present=nowithout starting anything, and--cudareaches a CPU emulation device, which the probe names rather than passing. "What was not run" lists every remaining step.
How this works, and why the checks are shaped this way
The guest gets no NVIDIA driver and no /dev/nvidia*. A compatibility libcuda.so.1 is
injected at /opt/smolvm-cuda inside the guest and forwards CUDA driver calls over vsock to a host
daemon that owns the device. Nothing is needed on the host beyond a working NVIDIA driver: no extra
packages, no container toolkit, no device plugin.
Because the API is remoted rather than passed through, a program can start, link against
libcuda.so.1 and exit zero without a GPU ever being reached. Assert a device name and a
transferred result, never an exit code.
Procedure
1. Preflight.
scripts/preflight.sh
Read-only: it starts no VM and touches no NVIDIA state. It reports the GPU and driver version,
whether your user can open /dev/kvm, and the host's own libcuda count. If the question is "can
this machine run CUDA", the preflight answers it and nothing else needs to run. result=blocked
with gpu_present=no saves the most time, because on a host with no NVIDIA GPU the probe starts a
VM, reaches a CPU emulation device and returns a passing round trip, which reads like a yes.
Verified on macOS arm64 on v1.16.1, v1.18.2 and v1.22.2: gpu_present=no and unsupported=cuda;
on v1.22.2 the note read macOS has no CUDA driver, so --cuda has nothing to reach here.
2. Run the probe.
scripts/run-cuda-probe.sh # python:3.12-slim
scripts/run-cuda-probe.sh <other glibc image>
It mounts scripts/ into the guest and runs cuda-probe.py under --cuda, then asserts two
values from the output:
device_named=ok
data_roundtrip=ok
device_kind=gpu
result=cuda_ok
On the A10 on v1.14.6, cuda-probe.py's own output was:
load_shim -> ok /opt/smolvm-cuda/libcuda.so.1
cuInit -> 0
cuDeviceGetCount -> 0 count = 1
cuDeviceGetName -> 0 name = NVIDIA A10
cuCtxCreate -> 0
cuMemGetInfo -> 0 total MiB = 22587
cuMemAlloc -> 0
cuMemcpyHtoD -> 0
cuMemcpyDtoH -> 0
roundtrip first 16 bytes match: True
cuMemFree -> 0
roundtrip ... True is the one that matters. It is the only line that proves bytes reached the
device.
3. Clean up. CUDA images are large.
scripts/cleanup.sh --purge
smolvm machine prune --name <NAME> --all # any persistent --cuda machine you kept
cleanup.sh waits up to 20 seconds, polling the machine list, and prints waiting=up to 20s
first: an ephemeral machine's entry retires after its run returns.
The probe runs are ephemeral and leave nothing to prune; machine prune takes a machine name and
is rejected without one.
--cuda changes nothing on the host: the shim is injected inside the guest only. Verified after a
series of CUDA runs plus a Kubernetes install and teardown on the same host, where
nvidia-smi still reported the device and a whole-filesystem sweep for *smolvm* came back empty.
Traps
Full detail in references/traps.md.
- A zero exit code proves nothing. The remoted API is why.
- A device name and a passing round trip do not prove a GPU either. When the host cannot load
the NVIDIA driver library, the host side answers with a CPU emulation device:
cuInit -> 0,cuDeviceGetCount -> 0 count = 1, `cuDeviceGetName -> 0
الأسئلة الشائعة
هل أحتاج إلى بطاقة NVIDIA؟
نعم. المهارة مخصصة لبطاقات NVIDIA، وعلى حاسوب بلا بطاقة منها تبلغ بعدم وجود معالج رسومي.
هل تعمل على Mac؟
لا مع معالج رسومي فعلي. تقول المهارة إن أجهزة Mac وبعض مضيفات Linux لا تحتوي على عتاد NVIDIA، فتحصل فقط على إجابة بعدم وجود معالج رسومي.
لماذا nvidia-smi غير موجود؟
لا يحصل الجهاز الضيف على تعريف NVIDIA ولا على ملفات أجهزة NVIDIA، لذلك تُوفَّر أدوات GPU عبر طبقة توافق بدلًا من ذلك.
التفاصيل
الوصف الأصلي من المؤلف
Runs CUDA compute workloads inside a smolvm microVM against a real host NVIDIA GPU, using smolvm's --cuda API remoting. Use when a workload in a machine needs a GPU; when nvidia-smi or /dev/nvidia* is missing inside a --cuda guest; when a CUDA program in a machine exits zero but seems not to touch the device; when the shim will not load in an Alpine image; or when checking whether CUDA is available on a given platform, including Windows. Do not use it for Vulkan graphics (--gpu), which is a separate feature, in docs/gpu.md, and do not expect it on a Mac, which has no CUDA driver.
repo: smol-machines/smolvm
الشعبية
- نجوم GitHub
- 6.9k
- الترتيب
- #13719
- الترخيص
- Apache-2.0
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
branch-and-checkpoint
6.9kيساعد وكيلك على حفظ جهاز smolvm افتراضي قيد التشغيل كنقاط حفظ، واستعادته لاحقًا، وإيقافه مؤقتًا واستئنافه، وتفريعه إلى نسخ.
coding-agent
6.9kيساعد وكيلك على تشغيل وكيل برمجة مثل Claude Code داخل جهاز smolvm افتراضي آمن مع ربط مجلد مشروعك.
credentials
6.9kيتيح لوكيلك استدعاء واجهة برمجية بمفتاحك دون أن يدخل المفتاح نفسه إلى جهازه الافتراضي، فلا يستطيع الكود غير الموثوق قراءته.
dev-env
6.9kيعلّم وكيلك إبقاء جهاز تطوير smolvm مع أدواته مثبتة، ليعود بسرعة ويحتفظ بالحزم بين الجلسات.
مهارات مشابهة
pytorch-patterns
280kيساعد وكيلك على استخدام PyTorch في نماذج تعلم الآلة. يطبّق أفضل الممارسات لتدريب النماذج بكفاءة ويضمن نتائج قابلة للتكرار.
evm-token-decimals
280kيساعد وكيلك على تجنب أخطاء الأعداد العشرية عبر شبكات البلوكتشين المختلفة. يضمن دقة قيم الرموز في المعاملات والحسابات.
ito-inference
280kيتيح لوكيلك التحقق من توفر نماذج الذكاء الاصطناعي للاستخدام. يربط طلب الحوسبة بخدمة النموذج الجاهزة.