Upload docker-compose-runner.sh with huggingface_hub
Browse files- docker-compose-runner.sh +140 -0
docker-compose-runner.sh
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# ========================================
|
| 4 |
+
# Docker Compose Script for LatentRoute
|
| 5 |
+
# ========================================
|
| 6 |
+
|
| 7 |
+
set -e
|
| 8 |
+
|
| 9 |
+
# Colors for output
|
| 10 |
+
RED='\033[0;31m'
|
| 11 |
+
GREEN='\033[0;32m'
|
| 12 |
+
YELLOW='\033[1;33m'
|
| 13 |
+
BLUE='\033[0;34m'
|
| 14 |
+
NC='\033[0m'
|
| 15 |
+
|
| 16 |
+
print_info() {
|
| 17 |
+
echo -e "${BLUE}ℹ️ $1${NC}"
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
print_success() {
|
| 21 |
+
echo -e "${GREEN}✅ $1${NC}"
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
print_warning() {
|
| 25 |
+
echo -e "${YELLOW}⚠️ $1${NC}"
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
print_error() {
|
| 29 |
+
echo -e "${RED}❌ $1${NC}"
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
show_usage() {
|
| 33 |
+
cat << EOF
|
| 34 |
+
Usage: $0 [COMMAND] [OPTIONS]
|
| 35 |
+
|
| 36 |
+
COMMANDS:
|
| 37 |
+
build Build Docker image
|
| 38 |
+
up Start training container
|
| 39 |
+
down Stop and remove containers
|
| 40 |
+
logs Show container logs
|
| 41 |
+
shell Open interactive bash in running container
|
| 42 |
+
push Push image to registry
|
| 43 |
+
clean Remove image and volumes
|
| 44 |
+
|
| 45 |
+
OPTIONS (for up):
|
| 46 |
+
--gpus NUM Number of GPUs (default: 1)
|
| 47 |
+
--compose-file Path to docker-compose.yml (default: docker-compose.yml)
|
| 48 |
+
|
| 49 |
+
EXAMPLES:
|
| 50 |
+
./docker-compose-runner.sh build
|
| 51 |
+
./docker-compose-runner.sh up --gpus 4
|
| 52 |
+
./docker-compose-runner.sh logs
|
| 53 |
+
./docker-compose-runner.sh shell
|
| 54 |
+
./docker-compose-runner.sh down
|
| 55 |
+
EOF
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
# Check if docker-compose is installed
|
| 59 |
+
if ! command -v docker-compose &> /dev/null; then
|
| 60 |
+
print_error "docker-compose not installed. Install it with: sudo apt install docker-compose"
|
| 61 |
+
exit 1
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# Check if .env.docker exists
|
| 65 |
+
if [ ! -f ".env.docker" ]; then
|
| 66 |
+
print_warning ".env.docker not found, creating from template..."
|
| 67 |
+
# Create basic .env.docker if it doesn't exist
|
| 68 |
+
touch .env.docker
|
| 69 |
+
fi
|
| 70 |
+
|
| 71 |
+
COMMAND="${1:-help}"
|
| 72 |
+
GPUS="${3:-1}"
|
| 73 |
+
COMPOSE_FILE="${COMPOSE_FILE:-docker-compose.yml}"
|
| 74 |
+
|
| 75 |
+
case $COMMAND in
|
| 76 |
+
build)
|
| 77 |
+
print_info "Building Docker image..."
|
| 78 |
+
docker-compose -f $COMPOSE_FILE build
|
| 79 |
+
print_success "Build complete!"
|
| 80 |
+
;;
|
| 81 |
+
|
| 82 |
+
up)
|
| 83 |
+
print_info "Starting training container..."
|
| 84 |
+
# Create necessary directories
|
| 85 |
+
mkdir -p models data logs
|
| 86 |
+
|
| 87 |
+
# Override GPU count if specified
|
| 88 |
+
if [ ! -z "$GPUS" ] && [ "$GPUS" != "1" ]; then
|
| 89 |
+
print_info "Setting GPU count to: $GPUS"
|
| 90 |
+
export NVIDIA_VISIBLE_DEVICES=$GPUS
|
| 91 |
+
fi
|
| 92 |
+
|
| 93 |
+
docker-compose -f $COMPOSE_FILE up -d latentroute-train
|
| 94 |
+
print_success "Container started!"
|
| 95 |
+
print_info "View logs: docker-compose -f $COMPOSE_FILE logs -f"
|
| 96 |
+
;;
|
| 97 |
+
|
| 98 |
+
down)
|
| 99 |
+
print_info "Stopping and removing containers..."
|
| 100 |
+
docker-compose -f $COMPOSE_FILE down
|
| 101 |
+
print_success "Containers stopped!"
|
| 102 |
+
;;
|
| 103 |
+
|
| 104 |
+
logs)
|
| 105 |
+
print_info "Showing logs..."
|
| 106 |
+
docker-compose -f $COMPOSE_FILE logs -f latentroute-train
|
| 107 |
+
;;
|
| 108 |
+
|
| 109 |
+
shell)
|
| 110 |
+
CONTAINER_ID=$(docker-compose -f $COMPOSE_FILE ps -q latentroute-train)
|
| 111 |
+
if [ -z "$CONTAINER_ID" ]; then
|
| 112 |
+
print_error "Container not running. Start it with: $0 up"
|
| 113 |
+
exit 1
|
| 114 |
+
fi
|
| 115 |
+
print_info "Opening shell in container..."
|
| 116 |
+
docker exec -it $CONTAINER_ID /bin/bash
|
| 117 |
+
;;
|
| 118 |
+
|
| 119 |
+
push)
|
| 120 |
+
print_info "Pushing image to registry..."
|
| 121 |
+
docker-compose -f $COMPOSE_FILE push
|
| 122 |
+
print_success "Image pushed!"
|
| 123 |
+
;;
|
| 124 |
+
|
| 125 |
+
clean)
|
| 126 |
+
print_warning "Removing Docker image and volumes..."
|
| 127 |
+
docker-compose -f $COMPOSE_FILE down -v
|
| 128 |
+
docker rmi latentroute:latest
|
| 129 |
+
print_success "Cleaned up!"
|
| 130 |
+
;;
|
| 131 |
+
|
| 132 |
+
ps|status)
|
| 133 |
+
print_info "Container status:"
|
| 134 |
+
docker-compose -f $COMPOSE_FILE ps
|
| 135 |
+
;;
|
| 136 |
+
|
| 137 |
+
help|*)
|
| 138 |
+
show_usage
|
| 139 |
+
;;
|
| 140 |
+
esac
|