File size: 2,078 Bytes
4112422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
83
84
85
86
87
88
89
90
# MinerU RunPod Serverless Deployment

## Overview

This deployment includes MinerU models directly in the Docker image for fast cold starts on RunPod Serverless.

## Build and Deploy

### 1. Build Docker Image

```bash
./build_runpod.sh
```

This will:
- Build the Docker image with all MinerU models included
- Download models during build (this takes ~10-15 minutes)
- Result in a Docker image of approximately 5-10GB

### 2. Push to Docker Hub

```bash
docker login
docker push marcosremar2/mineru-runpod:latest
```

### 3. Deploy on RunPod

1. Go to [RunPod Serverless](https://www.runpod.io/console/serverless)
2. Click "New Template"
3. Configure:
   - **Container Image**: `marcosremar2/mineru-runpod:latest`
   - **Container Disk**: 20 GB (to be safe)
   - **Volume Size**: 0 GB (not needed, models in image)
   - **GPU**: Any GPU with 8GB+ VRAM
   - **Max Workers**: Based on your needs
   - **Idle Timeout**: 5 seconds
   - **Execution Timeout**: 120 seconds

### 4. Test the Deployment

```bash
python test_runpod.py test.pdf https://api.runpod.ai/v2/YOUR_ENDPOINT_ID YOUR_API_KEY
```

## API Usage

### Request Format

```json
{
  "input": {
    "pdf_base64": "base64_encoded_pdf_content",
    "filename": "document.pdf"
  }
}
```

### Response Format

```json
{
  "output": {
    "markdown": "# Converted Document\n\nContent here...",
    "filename": "document.pdf",
    "status": "success",
    "pages": 5
  }
}
```

## Cost Estimation

- **Cold Start**: ~5-10 seconds (models already in image)
- **Processing**: ~10-30 seconds per PDF
- **GPU Cost**: ~$0.00024/second
- **Total per PDF**: ~$0.01-0.02

## Optimization Tips

1. **Reduce Image Size**: Remove unnecessary models from Dockerfile
2. **Use Active Workers**: For consistent load, keep 1-2 active workers
3. **Adjust Timeout**: Increase for larger PDFs
4. **Monitor Usage**: Use RunPod dashboard to track costs

## Troubleshooting

1. **Out of Memory**: Use larger GPU (16GB+ VRAM)
2. **Timeout**: Increase execution timeout in template
3. **Model Loading**: Check MINERU_MODEL_PATH environment variable