Skip to content

Instantly share code, notes, and snippets.

@cenkce
Last active August 16, 2026 20:23
Show Gist options
  • Select an option

  • Save cenkce/f7a333733e1720da3eda3fddd34a7772 to your computer and use it in GitHub Desktop.

Select an option

Save cenkce/f7a333733e1720da3eda3fddd34a7772 to your computer and use it in GitHub Desktop.
fix: fix G4 runtime errors
#!/bin/bash
# Ensure working directory is /content
cd /content
## G4 runtime fixes
pip uninstall flashinfer
export VLLM_USE_FLASHINFER=0
export VLLM_USE_FLASHINFER_SAMPLER=0
# 1. Clean up old processes and conflicting dependencies
pkill -9 -f "vllm.entrypoints" 2>/dev/null || true
pkill -9 -f "cloudflared" 2>/dev/null || true
pip uninstall -y -q torchaudio 2>/dev/null || true
rm -f /content/cloudflare.log /content/vllm.log
# 2. Check and install Cloudflare tunnel binary if not present
if ! command -v cloudflared &> /dev/null; then
wget -q -nc https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
dpkg -i cloudflared-linux-amd64.deb > /dev/null 2>&1
fi
# 3. Start vLLM server in daemon mode (262k Context)
echo "1. Starting vLLM daemon (Qwen/Qwen3.8-27B, 262k context)..."
nohup python3 -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3.8-27B \
--port 8000 \
--dtype bfloat16 \
--max-model-len 262144 \
--gpu-memory-utilization 0.92 \
--enforce-eager \
--enable-auto-tool-choice \
--tool-call-parser qwen3_coder \
--reasoning-parser deepseek_r1 \
--attention-backend flash_attn \
--trust-remote-code > /content/vllm.log 2>&1 &
VLLM_PID=$!
# 4. Check for immediate startup/argument errors (within first 2 seconds)
sleep 2
if ! kill -0 $VLLM_PID 2>/dev/null; then
echo -e "\n❌ vLLM failed to start due to argument/configuration errors! Logs:"
cat /content/vllm.log
exit 1
fi
# 5. Wait for model loading and health check
echo -n "⏳ Loading model weights into GPU memory, please wait"
READY=0
for i in {1..60}; do
if ! kill -0 $VLLM_PID 2>/dev/null; then
echo -e "\n❌ vLLM process terminated unexpectedly! Error logs:"
tail -n 35 /content/vllm.log
exit 1
fi
if curl -s -f http://localhost:8000/health > /dev/null 2>&1; then
echo -e "\n✅ vLLM server is healthy and ready!"
READY=1
break
fi
echo -n "."
sleep 3
done
if [ "$READY" -ne 1 ]; then
echo -e "\n❌ Timeout: vLLM server failed to become ready in time."
tail -n 35 /content/vllm.log
exit 1
fi
# 6. Start Cloudflare tunnel in the background
echo -e "\n2. Establishing Cloudflare tunnel..."
nohup cloudflared tunnel --url http://127.0.0.1:8000 > /content/cloudflare.log 2>&1 &
# 7. Extract the public tunnel URL
TUNNEL_URL=""
for i in {1..30}; do
if [ -f /content/cloudflare.log ]; then
TUNNEL_URL=$(grep -o 'https://[a-zA-Z0-9-]*\.trycloudflare\.com' /content/cloudflare.log | head -n 1)
if [ -n "$TUNNEL_URL" ]; then
break
fi
fi
sleep 1
done
# 8. Print connection details
echo "================================================================="
if [ -n "$TUNNEL_URL" ]; then
echo "🚀 PUBLIC API URL : $TUNNEL_URL"
echo "👉 OPENAI BASE URL : $TUNNEL_URL/v1"
else
echo "❌ Failed to retrieve Cloudflare URL. cloudflare.log contents:"
cat /content/cloudflare.log
fi
echo "🤖 MODEL : Qwen/Qwen3.8-27B"
echo "🧠 CONTEXT SIZE : 262,144 tokens"
echo "🛠️ TOOL CALLING : Enabled (qwen3_coder parser)"
echo "================================================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment