109 lines
2.9 KiB
Bash
109 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Fix Docker Model Runner permission issues
|
|
echo "=== Fixing Docker Model Runner Permission Issues ==="
|
|
echo ""
|
|
|
|
# Stop any running containers
|
|
echo "Stopping existing containers..."
|
|
docker-compose down --remove-orphans 2>/dev/null || true
|
|
docker rm -f docker-model-runner amd-model-runner 2>/dev/null || true
|
|
|
|
# Create directories with proper permissions
|
|
echo "Creating directories with proper permissions..."
|
|
mkdir -p models data config
|
|
chmod -R 777 models data config
|
|
|
|
# Create a simple test model file
|
|
echo "Creating test model file..."
|
|
cat > models/current_model.gguf << 'EOF'
|
|
# This is a placeholder GGUF model file
|
|
# Replace with a real GGUF model for actual use
|
|
# Download from: https://huggingface.co/TheBloke
|
|
EOF
|
|
|
|
# Set proper ownership (try different approaches)
|
|
echo "Setting file permissions..."
|
|
chmod 666 models/current_model.gguf
|
|
chmod 666 models/layout.json 2>/dev/null || true
|
|
chmod 666 models/models.json 2>/dev/null || true
|
|
|
|
# Create a working Docker Compose configuration
|
|
echo "Creating working Docker Compose configuration..."
|
|
cat > docker-compose.working.yml << 'COMPOSE'
|
|
version: '3.8'
|
|
|
|
services:
|
|
# Working AMD GPU Model Runner
|
|
amd-model-runner:
|
|
image: ghcr.io/ggerganov/llama.cpp:server
|
|
container_name: amd-model-runner
|
|
privileged: true
|
|
user: "0:0" # Run as root
|
|
ports:
|
|
- "11434:8080" # Main API port
|
|
- "8083:8080" # Alternative port
|
|
environment:
|
|
- HSA_OVERRIDE_GFX_VERSION=11.0.0
|
|
- GPU_LAYERS=35
|
|
- THREADS=8
|
|
- BATCH_SIZE=512
|
|
- CONTEXT_SIZE=4096
|
|
devices:
|
|
- /dev/kfd:/dev/kfd
|
|
- /dev/dri:/dev/dri
|
|
group_add:
|
|
- video
|
|
volumes:
|
|
- ./models:/models:rw
|
|
- ./data:/data:rw
|
|
working_dir: /models
|
|
restart: unless-stopped
|
|
command: >
|
|
--model /models/current_model.gguf
|
|
--host 0.0.0.0
|
|
--port 8080
|
|
--n-gpu-layers 35
|
|
--threads 8
|
|
--batch-size 512
|
|
--ctx-size 4096
|
|
--parallel
|
|
--cont-batching
|
|
--keep-alive 300
|
|
--log-format json
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
networks:
|
|
default:
|
|
driver: bridge
|
|
COMPOSE
|
|
|
|
echo ""
|
|
echo "=== Starting Fixed Container ==="
|
|
docker-compose -f docker-compose.working.yml up -d amd-model-runner
|
|
|
|
echo ""
|
|
echo "=== Checking Container Status ==="
|
|
sleep 5
|
|
docker ps | grep amd-model-runner
|
|
|
|
echo ""
|
|
echo "=== Container Logs ==="
|
|
docker logs amd-model-runner | tail -10
|
|
|
|
echo ""
|
|
echo "=== Testing File Access ==="
|
|
docker exec amd-model-runner ls -la /models/ 2>/dev/null || echo "Container not ready yet"
|
|
|
|
echo ""
|
|
echo "=== Next Steps ==="
|
|
echo "1. Check logs: docker logs -f amd-model-runner"
|
|
echo "2. Test API: curl http://localhost:11434/health"
|
|
echo "3. Replace models/current_model.gguf with a real GGUF model"
|
|
echo "4. If still having issues, try: docker exec amd-model-runner chmod 666 /models/*"
|