搜索

PythonReactSEOPDF
GitHub Skill

cpu-mode-assertions-torch

Assert CPU-only runtime inside a container using PyTorch (torch.cuda.is_available()==False) and optional env var checks. Use to prevent accidental GPU execution during CPU smoke tests.

jfriisj☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Skill Instructions

Inputs

  • SERVICE_CONTAINER (string): container name to exec into
  • CPU_DEVICE_ENV (string, optional): env var to validate (e.g. ASR_DEVICE)
  • CPU_DEVICE_EXPECTED (string, optional): expected value (e.g. cpu)

Procedure

set -euo pipefail

service_container="${SERVICE_CONTAINER:?SERVICE_CONTAINER is required}"

# 1) Env assertion (optional)
if [ -n "${CPU_DEVICE_ENV:-}" ]; then
  docker exec "$service_container" printenv "$CPU_DEVICE_ENV"
fi

# 2) Runtime assertion (torch)
docker exec "$service_container" python - <<'PY'
import torch
print('torch_version=', torch.__version__)
print('torch_cuda_is_available=', torch.cuda.is_available())
print('torch_cuda_version=', getattr(torch.version, 'cuda', None))
PY

Acceptance Criteria

  • torch_cuda_is_available prints False
  • If CPU_DEVICE_ENV is provided, its value equals CPU_DEVICE_EXPECTED (or cpu if you standardize it)

Why

Prevents “silent GPU path” during CPU smoke testing (different behavior, heavier images, device-specific bugs).

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!