Langsung ke konten
Skillpedia
Agen48k Β· #4851

huggingface-zerogpu

Fungsinya

Tool ini membantu Anda menjalankan demo AI yang membutuhkan daya pemrosesan GPU. Tool ini mengelola akses ke GPU secara efisien sehingga Anda bisa menjalankan model AI tanpa perlu GPU yang kuat di komputer sendiri.

Kapan dipakai

  • βœ“Ketika Anda ingin menunjukkan model AI yang sedang bekerja kepada orang lain.
  • βœ“Ketika kode AI Anda membutuhkan GPU agar berjalan cepat, tetapi Anda tidak memilikinya.
  • βœ“Ketika menyiapkan proyek AI yang menggunakan fitur GPU tertentu.

Link skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/huggingface-zerogpu/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/huggingface-zerogpu/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBagaimana cara membuat model AI saya menggunakan GPU agar berjalan lebih cepat?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Tool ini mengonfigurasi kode Anda agar menggunakan GPU jarak jauh. Tool ini memastikan bagian kode yang memakai GPU hanya berjalan saat dibutuhkan dan mengatur bagaimana data dikirim ke GPU.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Hugging Face ZeroGPU

When to Use

Use this skill when you need aI demos and GPU compute with Gradio Spaces and Hugging Face Spaces ZeroGPU. Use when writing or reviewing code that uses @spaces.GPU, configuring python_version or requirements.txt for a ZeroGPU Space, or handling ZeroGPU-specific code constraints β€” pickle-based process...

Rules and patterns for ML demos on Hugging Face Spaces with ZeroGPU hardware. Covers @spaces.GPU, duration and quota tuning, process isolation, the CUDA availability model, concurrency safety, and CUDA build constraints.

Scope

This skill is for Gradio SDK Spaces using ZeroGPU hardware. Docker and Static Spaces cannot schedule onto ZeroGPU, and Streamlit apps now run as Docker Spaces β€” so this skill applies only to Gradio. For general Gradio coding (components, layouts, event listeners), see the huggingface-gradio skill in this repo. The authoritative ZeroGPU docs live at https://huggingface.co/docs/hub/spaces-zerogpu β€” refer to them for the current backing GPU, runtime version lists, and tier thresholds, all of which change over time.

Reference Files

Reference When to read
references/concurrency.md Always read alongside SKILL.md when writing ZeroGPU code β€” handlers run in parallel by default
references/how-zerogpu-works.md When reasoning about cold-starts, worker reuse, why module-scope warmup does not carry to requests, or why returning CUDA tensors hangs
references/how-quota-works.md When choosing duration values, debugging illegal duration vs quota exceeded errors, or explaining why default 60s blocks short tasks
references/cuda-and-deps.md When installing CUDA-dependent packages (e.g. flash-attn), pinning torch side-cars, or reading wheel filename tags

Hardware

ZeroGPU exposes two GPU sizes that map to a fraction of the backing card:

size Slice of backing GPU Quota cost
large (default) Half 1x
xlarge Full 2x

Default large gives half a physical GPU, so memory bandwidth and compute are significantly lower than the full card's specs. Use xlarge only when the workload genuinely needs the extra memory or compute.

Backing GPU changes without notice. ZeroGPU has already migrated across GPU generations several times; older write-ups may name A100 or H200, but those are outdated. For the current backing GPU and exact per-size VRAM, always check the ZeroGPU docs before sizing workloads.

Basic Pattern

import spaces
import torch
from transformers import pipeline

pipe = pipeline("text-generation", model="...", device="cuda")

@spaces.GPU
def generate(prompt: str) -> str:
    return pipe(prompt, max_new_tokens=100)[0]["generated_text"]

Key rules:

  1. Instantiate models at module scope and call .to("cuda") eagerly. ZeroGPU handles the actual device mapping transparently (see CUDA availability model below).
  2. Decorate GPU functions with @spaces.GPU. The decorator is a no-op outside ZeroGPU, so it is safe to keep in all environments.
  3. Set duration to match the realistic worst-case workload (default 60s). The platform pre-checks requested duration against the user's remaining quota β€” not against the actual run time β€” so a 10-second task left at the 60s default fails with quota exceeded as soon as the user's remaining quota drops below 60s. Smaller declared duration also ranks higher in the node-level queue. See "Duration and Quota" below.
  4. torch.compile is NOT supported. Use PyTorch ahead-of-time compilation (AoTI) (torch 2.8+) instead.
  5. Use size="xlarge" sparingly. It allocates the full backing GPU, but costs 2x quota and tends to queue longer.
@spaces.GPU(duration=120)
def generate_image(prompt: str):
    return pipe(prompt).images[0]

CUDA Availability Model

Real GPU access is only available inside @spaces.GPU-decorated functions. Outside those functions, the GPU is not attached to the process.

However, import spaces monkey-patches torch so that:

  • torch.cuda.is_available() returns True globally.
  • .to("cuda") / device="cuda" calls at module scope succeed without error.

…

Pertanyaan umum

Apa itu 'ZeroGPU'?

ZeroGPU adalah sistem yang memungkinkan Anda menggunakan GPU yang kuat tanpa harus memiliki GPU secara fisik. Sistem ini mengatur akses ke GPU tersebut untuk menjalankan aplikasi AI.

Apakah ini bisa dipakai untuk semua jenis aplikasi AI?

Tool ini khusus untuk aplikasi berbasis Gradio Spaces yang membutuhkan GPU. Jenis proyek lain mungkin tidak bisa digunakan.

Mengapa kode saya tidak berjalan di luar fungsi yang diberi decorator @spaces.GPU?

GPU hanya benar-benar tersedia di dalam fungsi yang ditandai dengan @spaces.GPU. Di luar fungsi tersebut, tool mensimulasikan akses untuk menyiapkan kode, tetapi komputasi berat hanya dijalankan di tempat yang tepat.

Detail

Deskripsi asli dari pembuat

AI demos and GPU compute with Gradio Spaces and Hugging Face Spaces ZeroGPU.

repo: sickn33/agentic-awesome-skills

Popularitas

Bintang GitHub
48k
Peringkat
#4851
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa