by davila7
科学计算任务需要适当的硬件资源才能高效运行。此技能可自动检测CPU核心、GPU可用性、内存和磁盘空间,以推荐最佳计算策略和库选择。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 get-available-resources 技能" 开始使用
=== get-available-resources 技能 === 作者: davila7 描述: 科学计算任务需要适当的硬件资源才能高效运行。此技能可自动检测CPU核心、GPU可用性、内存和磁盘空间,以推荐最佳计算策略和库选择。 使用方法: 1. 调用技能: "使用 get-available-resources 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 get-available-resources 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
data
safe
Detect available computational resources and generate strategic recommendations for scientific computing tasks. This skill automatically identifies CPU capabilities, GPU availability (NVIDIA CUDA, AMD ROCm, Apple Silicon Metal), memory constraints, and disk space to help make informed decisions about computational approaches.
Use this skill proactively before any computationally intensive task:
Example scenarios:
The skill runs scripts/detect_resources.py to automatically detect:
CPU Information
GPU Information
Memory Information
Disk Space Information
Operating System Information
The skill generates a .claude_resources.json file in the current working directory containing:
{
"timestamp": "2025-10-23T10:30:00",
"os": {
"system": "Darwin",
"release": "25.0.0",
"machine": "arm64"
},
"cpu": {
"physical_cores": 8,
"logical_cores": 8,
"architecture": "arm64"
},
"memory": {
"total_gb": 16.0,
"available_gb": 8.5,
"percent_used": 46.9
},
"disk": {
"total_gb": 500.0,
"available_gb": 200.0,
"percent_used": 60.0
},
"gpu": {
"nvidia_gpus": [],
"amd_gpus": [],
"apple_silicon": {
"name": "Apple M2",
"type": "Apple Silicon",
"backend": "Metal",
"unified_memory": true
},
"total_gpus": 1,
"available_backends": ["Metal"]
},
"recommendations": {
"parallel_processing": {
"strategy": "high_parallelism",
"suggested_workers": 6,
"libraries": ["joblib", "multiprocessing", "dask"]
},
"memory_strategy": {
"strategy": "moderate_memory",
"libraries": ["dask", "zarr"],
"note": "Consider chunking for datasets > 2GB"
},
"gpu_acceleration": {
"available": true,
"backends": ["Metal"],
"suggested_libraries": ["pytorch-mps", "tensorflow-metal", "jax-metal"]
},
"large_data_handling": {
"strategy": "disk_abundant",
"note": "Sufficient space for large intermediate files"
}
}
}
The skill generates context-aware recommendations:
Parallel Processing Recommendations:
Memory Strategy Recommendations:
GPU Acceleration Recommendations:
Large Data Handling Recommendations:
Execute the detection script at the start of any computationally intensive task:
python scripts/detect_resources.py
Optional arguments:
-o, --output <path>: Specify custom output path (default: .claude_resources.json)-v, --verbose: Print full resource information to stdoutAfter running detection, read the generated .claude_resources.json file to inform computational decisions:
# Example: Use recommendations in code
import json
with open('.claude_resources.json', 'r') as f:
resources = json.load(f)
# Check parallel processing strategy
if resources['recommendations']['parallel_processing']['strategy'] == 'high_parallelism':
n_jobs = resources['recommendations']['parallel_processing']['suggested_workers']
# Use joblib, Dask, or multiprocessing with n_jobs workers
# Check memory strategy
if resources['recommendations']['memory_strategy']['strategy'] == 'memory_constrained':
# Use Dask, Zarr, or H5py for out-of-core processing
import dask.array as da
# Load data in chunks
# Check GPU availability
if resources['recommendations']['gpu_acceleration']['available']:
backends = resources['recommendations']['gpu_acceleration']['backends']
# Use appropriate GPU library based on available backend
Use the resource information and recommendations to make strategic choices:
For data loading:
memory_available_gb = resources['memory']['available_gb']
dataset_size_gb = 10
if dataset_size_gb > memory_available_gb * 0.5:
# Dataset is large relative to memory, use Dask
import dask.dataframe as dd
df = dd.read_csv('large_file.csv')
else:
# Dataset fits in memory, use pandas
import pandas as pd
df = pd.read_csv('large_file.csv')
For parallel processing:
from joblib import Parallel, delayed
n_jobs = resources['recommendations']['parallel_processing'].get('suggested_workers', 1)
results = Parallel(n_jobs=n_jobs)(
delayed(process_function)(item) for item in data
)
For GPU acceleration:
import torch
if 'CUDA' in resources['gpu']['available_backends']:
device = torch.device('cuda')
elif 'Metal' in resources['gpu']['available_backends']:
device = torch.device('mps')
else:
device = torch.device('cpu')
model = model.to(device)
The detection script requires the following Python packages:
uv pip install psutil
All other functionality uses Python standard library modules (json, os, platform, subprocess, sys, pathlib).
.claude_resources.json file in project directories to document resource-aware decisionsGPU not detected:
Script execution fails:
uv pip install psutilchmod +x scripts/detect_resources.pyInaccurate memory readings:
View Count
0
Download Count
0
Favorite Count
0
Quality Score
71