Spaces:
Runtime error
Runtime error
File size: 2,295 Bytes
aba8087 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#!/bin/bash
# setup.sh - Setup script for DeepCoder deployment
set -e
echo "π DeepCoder Model Setup"
echo "========================"
# Create necessary directories
echo "π Creating directories..."
mkdir -p models cache logs ssl
# Set permissions
chmod 755 models cache logs
chmod 700 ssl
# Check for GPU support
echo "π Checking GPU support..."
if command -v nvidia-smi &> /dev/null; then
echo "β
NVIDIA GPU detected:"
nvidia-smi --query-gpu=gpu_name,memory.total --format=csv,noheader
# Check for Docker GPU support
if docker run --rm --gpus all nvidia/cuda:11.8-base nvidia-smi &> /dev/null; then
echo "β
Docker GPU support verified"
export GPU_SUPPORT=true
else
echo "β οΈ Docker GPU support not available"
export GPU_SUPPORT=false
fi
else
echo "β οΈ No GPU detected. Running on CPU."
export GPU_SUPPORT=false
fi
# Build and start containers
echo "ποΈ Building Docker containers..."
docker-compose build
echo "π Starting services..."
if [ "$GPU_SUPPORT" = true ]; then
docker-compose up -d
else
# Remove GPU requirements for CPU-only deployment
sed 's/devices:/# devices:/g' docker-compose.yml | \
sed 's/- driver: nvidia/# - driver: nvidia/g' | \
sed 's/count: 1/# count: 1/g' | \
sed 's/capabilities: \[gpu\]/# capabilities: [gpu]/g' > docker-compose-cpu.yml
docker-compose -f docker-compose-cpu.yml up -d
fi
# Wait for services to be ready
echo "β³ Waiting for services to start..."
sleep 30
# Health check
echo "π₯ Performing health check..."
for i in {1..10}; do
if curl -f http://localhost:8000/health > /dev/null 2>&1; then
echo "β
DeepCoder API is healthy!"
break
else
echo "β³ Waiting for API to be ready... (attempt $i/10)"
sleep 10
fi
done
# Show status
echo "π Service Status:"
docker-compose ps
echo ""
echo "π DeepCoder setup complete!"
echo "API endpoint: http://localhost:8000"
echo "Health check: http://localhost:8000/health"
echo "Model info: http://localhost:8000/model/info"
echo ""
echo "To test the API:"
echo "curl -X POST http://localhost:8000/generate \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"prompt\": \"def fibonacci(n):\", \"max_tokens\": 200}'"
|