Skip to content

Commit 90a4544

Browse files
yasinBursaliclaude
andcommitted
fix(dream-cli): Apple GPU output polish — integer gpu_cores + Apple-aware header
cmd_status_json emitted gpu_cores as a JSON string via --arg. Switch to --argjson with integer-or-null detection: numeric gpu_cores become JSON integers, the literal "?" from system_profiler fallback becomes JSON null. dream gpu status header hardcoded "(0 GPUs)" derived from nvidia-smi. Branch on GPU_BACKEND=apple to show "(1 integrated GPU)" instead. Non-apple paths keep the existing behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4916453 commit 90a4544

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

dream-server/dream-cli

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ cmd_status_json() {
772772
--arg backend "apple" \
773773
--arg chip "$_chip" \
774774
--argjson unified_memory_gb "$_total_mem_gb" \
775-
--arg gpu_cores "$_gpu_cores" \
775+
--argjson gpu_cores "$([[ "$_gpu_cores" =~ ^[0-9]+$ ]] && printf '%s' "$_gpu_cores" || printf 'null')" \
776776
'{backend: $backend, chip: $chip, unified_memory_gb: $unified_memory_gb, gpu_cores: $gpu_cores}')
777777
elif command -v nvidia-smi >/dev/null 2>&1; then
778778
# Represent each GPU line as raw strings in an array
@@ -2536,11 +2536,15 @@ _gpu_status() {
25362536
check_install
25372537
load_env
25382538

2539-
local gpu_count
2540-
gpu_count=$(nvidia-smi --list-gpus 2>/dev/null | wc -l | tr -d ' ') || gpu_count=0
2541-
2542-
echo -e "${BLUE}━━━ GPU Status (${gpu_count} GPU$([ "$gpu_count" -ne 1 ] && echo s)) ━━━${NC}"
2543-
echo ""
2539+
if [[ "${GPU_BACKEND:-}" == "apple" ]]; then
2540+
echo -e "${BLUE}━━━ GPU Status (1 integrated GPU) ━━━${NC}"
2541+
echo ""
2542+
else
2543+
local gpu_count
2544+
gpu_count=$(nvidia-smi --list-gpus 2>/dev/null | wc -l | tr -d ' ') || gpu_count=0
2545+
echo -e "${BLUE}━━━ GPU Status (${gpu_count} GPU$([ "$gpu_count" -ne 1 ] && echo s)) ━━━${NC}"
2546+
echo ""
2547+
fi
25442548

25452549
if [[ "${GPU_BACKEND:-nvidia}" == "nvidia" ]] && command -v nvidia-smi &>/dev/null && [ "$gpu_count" -gt 0 ]; then
25462550
local output

0 commit comments

Comments
 (0)