Chuyển đến nội dung
Skillpedia
Công việc và dự án51k · #3471

get-available-resources

Skill này làm gì

Công cụ này kiểm tra các tài nguyên máy tính (như CPU, bộ nhớ và ổ đĩa) có sẵn cho một chương trình cụ thể. Nó tạo bản tóm tắt an toàn và đơn giản về các tài nguyên này để hỗ trợ lập kế hoạch.

Khi nào nên dùng

  • ✓Khi bạn cần lên kế hoạch cho một chương trình sử dụng nhiều tài nguyên.
  • ✓Trước khi chạy tác vụ có thể tiêu tốn nhiều bộ nhớ hoặc sức xử lý.
  • ✓Để hiểu giới hạn tài nguyên của một môi trường máy tính.

Liên kết skill

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/get-available-resources/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/get-available-resources/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Kiểm tra tài nguyên khả dụng để lên kế hoạch cho tác vụ của tôi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích môi trường hiện tại của chương trình, kiểm tra giới hạn CPU, bộ nhớ, ổ đĩa và các tài nguyên khác. Nó tạo báo cáo dữ liệu (JSON) cho thấy những gì khả dụng, mà không kiểm tra thử giới hạn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Get Available Resources

Build a conservative picture of resources available to the current process. Keep host inventory, process affinity, cgroup/container limits, scheduler allocation, and accelerator runtime usability separate.

Safety contract

Follow these rules:

  • Run detection when the user requests it or a specific workload needs resource planning. Do not persist a fingerprint for every scientific task.
  • Use stdout by default. Persist only when the user chooses an explicit generic local filename.
  • Do not run stress tests, benchmarks, large allocations, write probes, device resets, driver installation, or clock/power changes.
  • Do not dump the environment. Read only the named Slurm and accelerator variables implemented by the detector.
  • Do not report hostnames, absolute paths, cgroup paths, job IDs, device UUIDs, PCI addresses, or raw visibility-variable values.
  • Treat a missing observation as unknown. Never convert unknown to unlimited.
  • Never infer that a visible host CPU, memory pool, or GPU is usable inside a scheduler allocation or container.

The bundled detector uses only fixed executable/argument tuples, no shell, short timeouts, bounded stdout/stderr, and partial-failure warnings.

Quick start

Run from this skill directory.

Ephemeral stdout snapshot

python scripts/detect_resources.py

The command emits only JSON to stdout. Redirect it only when ordinary shell permissions are acceptable.

Explicit private file

python scripts/detect_resources.py --output resource-snapshot.json

Explicit output is restricted to one .json filename in the current directory, uses mode 0600 on POSIX, rejects symlinks and path traversal, and refuses overwrite unless --force is supplied. Forced output also rejects hard links and non-regular files. Windows privacy additionally depends on the directory ACL.

Optional psutil enhancement

The standard-library detector works without installation. For broader cross-platform physical-core, affinity, available-memory, swap, and disk coverage:

uv run --no-project --with "psutil==7.2.2" python scripts/detect_resources.py

The import is lazy. Failure to import psutil becomes a warning, not a fatal error.

Skip management-tool probes

python scripts/detect_resources.py --skip-accelerators

Use this when accelerator discovery latency is undesirable. The detector still summarizes the presence and state of allowlisted visibility variables without returning their values.

Required interpretation

CPU

Read these as different facts:

  • cpu.host.logical: system-visible scheduling units.
  • cpu.host.physical: physical topology, or null; never inferred from logical count.
  • cpu.process.affinity_logical: current affinity-set size when supported.
  • cpu.cgroup_v2.cpuset_logical: effective cgroup cpuset size.
  • cpu.cgroup_v2.quota_cores: finite cpu.max capacity, possibly fractional.
  • scheduler.allocation.cpu_per_process: bounded Slurm per-task interpretation when scope is clear.
  • cpu.effective.capacity_cores: minimum positive observed constraint.
  • cpu.effective.worker_ceiling: conservative floor for CPU process workers.

A quota of 1.5 is CPU-time capacity, not 1.5 physical cores. Affinity and cpusets constrain placement; quota constrains bandwidth.

Memory

Keep these separate:

  • host total/available memory;
  • current cgroup usage, hard memory.max, and remaining hierarchical capacity;
  • memory.high, which is a pressure/throttle boundary rather than a hard cap;
  • scheduler memory allocation and its scope; and
  • conservative effective hard limit and available estimate.

On Apple silicon, memory.model is unified_cpu_gpu. Do not add integrated GPU memory to RAM or describe it as separate VRAM.

Accelerators

Each device is a backend candidate:

  • NVIDIA GPU → CUDA candidate;
  • AMD GPU → ROCm candidate;
  • Apple integrated GPU → Metal candidate.

Management-query visibility does not establish:

  1. scheduler/container permission;
  2. device-node access;
  3. driver/runtime compatibility;
  4. framework package compatibility; or
  5. operator/data-type support.

Therefore runtime_usable_devices remains null and each device says runtime_compatibility: not_tested. Visibility/allocation counts constrain the observed management records, not the number of framework devices. MIG and AMD partition enumeration can differ.

…

Câu hỏi thường gặp

“Tài nguyên” trong ngữ cảnh này là gì?

Đó là các thành phần máy tính mà chương trình dùng để chạy, như sức xử lý (CPU), bộ nhớ (RAM) và dung lượng ổ đĩa.

Tại sao báo cáo được gọi là “an toàn” và “đơn giản”?

Công cụ tránh thu thập thông tin nhạy cảm hoặc quá chi tiết (như tên tệp chính xác hay mã định danh hệ thống) và chỉ tập trung vào giới hạn tài nguyên để tránh làm quá tải hoặc lộ thông tin hệ thống.

Lập kế hoạch tài nguyên nghĩa là gì?

Nghĩa là dùng thông tin về tài nguyên khả dụng để quyết định cách chạy tác vụ hiệu quả, đảm bảo không bị lỗi do thiếu dung lượng hoặc ảnh hưởng đến các chương trình khác.

Chi tiết

Mô tả gốc của tác giả

Detects host inventory and effective CPU, memory, disk, scheduler, container, and accelerator limits when a user asks for resource-aware planning or before a clearly resource-sensitive local workload. Produces a redacted JSON snapshot and conservative planning helpers without stress tests or assuming visible host hardware is usable.

repo: K-Dense-AI/scientific-agent-skills

Độ phổ biến

Sao GitHub
51k
Vị trí xếp hạng
#3471
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự