---
updatedAt: 2026-04-10T15:40:21.000Z
agentTools:
  projectIndex: https://vi.developers.datature.com/llms.txt
---

# Troubleshoot Issues

This page covers the most common errors when running inference with [Datature Vi](https://vi.developers.datature.com/docs/vi-sdk): out-of-memory failures, slow performance, model loading problems, runtime errors, and unexpected outputs.

<ViCallout type="info" title="Before You Start">

- [Vi SDK installed](https://vi.developers.datature.com/docs/vi-sdk-installation) with inference dependencies
- A [trained model](https://vi.developers.datature.com/docs/train-a-model) loaded with [ViModel](https://vi.developers.datature.com/docs/load-models)
- Familiarity with [inference basics](https://vi.developers.datature.com/docs/run-inference)

[Get started with inference →](https://vi.developers.datature.com/docs/vi-sdk-inference)

</ViCallout>

## Out of memory errors

### GPU out of memory

**Symptoms:**

<CodeGroup>

```text Error output
CUDA out of memory. Tried to allocate X GB...
RuntimeError: CUDA error: out of memory
```

</CodeGroup>

**Step 1: Switch to 8-bit quantization**

<CodeGroup>

```python 8-bit quantization
from vi.inference import ViModel

model = ViModel(
    run_id="your-run-id",
    load_in_8bit=True,
    device_map="auto"
)
```

</CodeGroup>

**Step 2: If still OOM, switch to 4-bit**

<CodeGroup>

```python 4-bit quantization
model = ViModel(
    run_id="your-run-id",
    load_in_4bit=True,
    device_map="auto"
)
```

</CodeGroup>

**Step 3: Enable low CPU memory usage**

<CodeGroup>

```python Low CPU memory
model = ViModel(
    run_id="your-run-id",
    load_in_4bit=True,
    low_cpu_mem_usage=True,
    device_map="auto"
)
```

</CodeGroup>

**Step 4: Clear GPU cache before loading**

<CodeGroup>

```python Clear cache first
import torch
import gc

torch.cuda.empty_cache()
gc.collect()

model = ViModel(run_id="your-run-id", load_in_8bit=True)
```

</CodeGroup>

**Step 5: Process in smaller chunks**

<CodeGroup>

```python Smaller chunks
def process_in_chunks(model, images, chunk_size=25):
    results = []
    for i in range(0, len(images), chunk_size):
        chunk = images[i:i + chunk_size]
        batch_results = model(source=chunk)
        results.extend(batch_results)
        torch.cuda.empty_cache()
    return results
```

</CodeGroup>

See [improve performance](https://vi.developers.datature.com/docs/optimize-performance) for more memory management strategies.

### CPU out of memory

**Symptoms:**

<CodeGroup>

```text Error output
MemoryError
Killed (process terminated)
```

</CodeGroup>

<CodeGroup>

```python CPU OOM fixes
# Enable low CPU memory usage during loading
model = ViModel(run_id="your-run-id", low_cpu_mem_usage=True)

# Force model onto GPU instead of CPU
model = ViModel(run_id="your-run-id", device_map="cuda")
```

</CodeGroup>

If your machine has a GPU, make sure the model is loading there rather than staying on CPU.

## Model loading issues

### Model download fails

**Symptoms:**

<CodeGroup>

```text Error output
ValueError: Failed to download model
ConnectionError: Failed to connect
```

</CodeGroup>

**Check your credentials:**

<CodeGroup>

```python Verify credentials
import os

print(f"Secret Key set: {bool(os.getenv('DATATURE_VI_SECRET_KEY'))}")
print(f"Org ID set: {bool(os.getenv('DATATURE_VI_ORGANIZATION_ID'))}")
```

</CodeGroup>

**Verify the run ID exists and training is complete:**

<CodeGroup>

```python Check run status
import vi

client = vi.Client()
run = client.runs.get(run_id="your-run-id")
print(f"Status: {run.status.phase}")
# Status must be "completed" before you can download
```

</CodeGroup>

**Test network connectivity:**

<CodeGroup>

```python Test connection
import requests

try:
    response = requests.get("https://vi.datature.com", timeout=5)
    print(f"Connection OK: {response.status_code}")
except Exception as e:
    print(f"Connection failed: {e}")
```

</CodeGroup>

### Model loading hangs

**Symptoms:** Loading freezes with no progress for an extended period.

<CodeGroup>

```python Check disk space
import shutil

total, used, free = shutil.disk_usage("/")
print(f"Free space: {free // (2**30)} GB")
```

</CodeGroup>

If you have insufficient disk space, the download may stall. Clear old cached models and retry:

<CodeGroup>

```bash Clear model cache
rm -rf ~/.datature/vi/models/
```

</CodeGroup>

<CodeGroup>

```python Force re-download
model = ViModel(
    run_id="your-run-id",
    overwrite=True
)
```

</CodeGroup>

## Slow inference

### General slowness

**Symptoms:** Inference takes much longer than expected, or throughput is low.

**Use a GPU:**

<CodeGroup>

```python Verify GPU is in use
import torch

print(f"CUDA available: {torch.cuda.is_available()}")

model = ViModel(run_id="your-run-id", device_map="cuda")
```

</CodeGroup>

**Enable FP16 and Flash Attention 2:**

<CodeGroup>

```python Speed optimizations
model = ViModel(
    run_id="your-run-id",
    dtype="float16",
    attn_implementation="flash_attention_2",
    device_map="auto"
)
```

</CodeGroup>

**Use batch inference instead of single-image loops:**

<CodeGroup>

```python Batch vs loop
# Good: batch inference
results = model(source=["img1.jpg", "img2.jpg", "img3.jpg"])

# Slow: sequential single-image calls
for img in ["img1.jpg", "img2.jpg", "img3.jpg"]:
    result, error = model(source=img)
```

</CodeGroup>

### First inference is slow

**Symptom:** The first prediction takes much longer than subsequent ones.

This is expected behavior. The model runs initialization work on the first call. Add a warm-up call before your timed measurements:

<CodeGroup>

```python Warm-up inference
model = ViModel(run_id="your-run-id")

# Warm-up (discard result)
model(source="any_image.jpg")

# Subsequent calls will be faster
result, error = model(source="real_image.jpg")
```

</CodeGroup>

## Runtime errors

### File not found

**Symptoms:**

<CodeGroup>

```text Error output
FileNotFoundError: [Errno 2] No such file or directory: 'image.jpg'
```

</CodeGroup>

<CodeGroup>

```python Use absolute paths
import os
from pathlib import Path

image_path = os.path.abspath("image.jpg")
result, error = model(source=image_path)

# Or verify the file exists first
if Path("image.jpg").exists():
    result, error = model(source="image.jpg")
else:
    print("File not found")
```

</CodeGroup>

### Unsupported image format

**Symptoms:**

<CodeGroup>

```text Error output
PIL.UnidentifiedImageError: cannot identify image file
```

</CodeGroup>

<CodeGroup>

```python Convert to supported format
from PIL import Image

img = Image.open("image.webp")
img = img.convert("RGB")
img.save("image.jpg", "JPEG")

result, error = model(source="image.jpg")
```

</CodeGroup>

**Supported formats:** `.jpg`, `.jpeg`, `.png`, `.bmp`, `.gif`, `.tiff`, `.tif`, `.webp`

### Prompt length mismatch

**Symptoms:**

<CodeGroup>

```text Error output
ValueError: user_prompt length must match sources length
```

</CodeGroup>

<CodeGroup>

```python Match prompt and image counts
# Good: lengths match
results = model(
    source=["img1.jpg", "img2.jpg"],
    user_prompt=["Prompt 1", "Prompt 2"]
)

# Bad: one prompt for two images
results = model(
    source=["img1.jpg", "img2.jpg"],
    user_prompt=["Prompt 1"]  # raises ValueError
)
```

</CodeGroup>

## Result issues

### No grounded phrases

**Symptoms:** `result.grounded_phrases` attribute is missing or bounding boxes are not returned.

<CodeGroup>

```python Check task type support
info = ViModel.inspect(run_id="your-run-id")
print(f"Task type: {info.task_type}")
```

</CodeGroup>

Not all models support phrase grounding. If `info.task_type` is `VQA`, the model will not return bounding boxes. Load a model trained for phrase grounding, or omit the prompt to let the model use its default detection behavior.

Also check that you are accessing the correct field:

<CodeGroup>

```python Access grounded phrases correctly
from vi.inference.task_types.phrase_grounding import PhraseGroundingResponse

result, error = model(source="image.jpg")

if error is None and isinstance(result, PhraseGroundingResponse):
    print(f"Found {len(result.result.groundings)} objects")
    for grounding in result.result.groundings:
        print(f"  {grounding.phrase}: {grounding.grounding}")
```

</CodeGroup>

### Unexpected output format

**Symptom:** Accessing `result.caption` or `result.grounded_phrases` raises `AttributeError`.

The response field names depend on the response type. Always use `isinstance()` and access the correct fields:

<CodeGroup>

```python Check response type first
from vi.inference.task_types.vqa import VQAResponse
from vi.inference.task_types.phrase_grounding import PhraseGroundingResponse

result, error = model(source="image.jpg")

if error is None:
    if isinstance(result, VQAResponse):
        print(f"Answer: {result.result.answer}")
    elif isinstance(result, PhraseGroundingResponse):
        print(f"Caption: {result.result.sentence}")
    else:
        print(f"Raw output: {result.result}")
```

</CodeGroup>

[See complete prediction schemas →](https://vi.developers.datature.com/docs/prediction-schemas)

### Poor quality results

**Symptom:** Predictions are inaccurate or vague.

**Lower the temperature for factual tasks:**

<CodeGroup>

```python Deterministic config
result, error = model(
    source="image.jpg",
    user_prompt="Describe this image",
    generation_config={
        "temperature": 0.0,
        "max_new_tokens": 256,
        "do_sample": False
    }
)
```

</CodeGroup>

**Write more specific prompts:**

<CodeGroup>

```python Prompt specificity
# Too vague
"Tell me about this"

# Specific
"What objects are visible in this image and where are they located?"
```

</CodeGroup>

**Check training completion:**

<CodeGroup>

```python Verify model status
client = vi.Client()
run = client.runs.get(run_id="your-run-id")
print(f"Status: {run.status.phase}")
# "completed" means training and export are done
```

</CodeGroup>

## Permission errors

### Access denied

**Symptoms:**

<CodeGroup>

```text Error output
PermissionError: [Errno 13] Permission denied
HTTPError: 403 Forbidden
```

</CodeGroup>

<CodeGroup>

```python Check API access
import vi

client = vi.Client()
org = client.organizations
print(f"Organization: {org.name}")
```

</CodeGroup>

<CodeGroup>

```python Check file permissions
import os

file_path = "image.jpg"
if os.access(file_path, os.R_OK):
    print("File is readable")
else:
    print("Cannot read file, check permissions")

output_dir = "./results"
os.makedirs(output_dir, exist_ok=True)
```

</CodeGroup>

## Debugging tips

### Enable detailed logging

<CodeGroup>

```python Debug logging
import logging

logging.basicConfig(level=logging.DEBUG)

model = ViModel(run_id="your-run-id")
result, error = model(source="image.jpg")
```

</CodeGroup>

### Check system resources

<CodeGroup>

```python System resource check
import psutil
import torch

cpu_percent = psutil.cpu_percent()
ram_percent = psutil.virtual_memory().percent

print(f"CPU: {cpu_percent}%")
print(f"RAM: {ram_percent}%")

if torch.cuda.is_available():
    for i in range(torch.cuda.device_count()):
        allocated = torch.cuda.memory_allocated(i) / 1e9
        reserved = torch.cuda.memory_reserved(i) / 1e9
        print(f"GPU {i}: Allocated: {allocated:.2f} GB, Reserved: {reserved:.2f} GB")
```

</CodeGroup>

### Build a minimal reproducible example

When reporting an issue, include a minimal script that shows the problem:

<CodeGroup>

```python Minimal repro
from vi.inference import ViModel
import vi, sys, torch

print(f"Vi SDK: {vi.__version__}")
print(f"Python: {sys.version}")
print(f"PyTorch: {torch.__version__}")
print(f"CUDA: {torch.version.cuda if torch.cuda.is_available() else 'N/A'}")

model = ViModel(run_id="your-run-id")
result, error = model(source="test.jpg")

if error:
    print(f"Error: {type(error).__name__}: {error}")
else:
    print(f"Success: {str(result.result)[:50]}...")
```

</CodeGroup>

## Getting help

If these steps don't resolve your issue:

<Steps>
  <Step stepNumber="1" title="Check result.raw_output for the full unprocessed model output" />
  <Step stepNumber="2" title="Review the Vi SDK changelog for known issues">
    Review the [Vi SDK changelog](https://vi.developers.datature.com/docs/vi-sdk-changelog) for known issues
  </Step>
  <Step stepNumber="3" title="Ask in the Datature community">
    Ask in the [Datature community](https://community.datature.com)
  </Step>
  <Step stepNumber="4" title="Contact Datature support">
    [Contact Datature support](https://vi.developers.datature.com/docs/contact-us)
  </Step>
</Steps>

When reaching out, include your Vi SDK version, Python version, GPU details, the complete error message, and a minimal reproducible script.

## Related resources

<BentoGrid className="grid grid-cols-1 md:grid-cols-2 gap-6 my-10">
  <BentoCard
    title="Improve Performance"
    description="Memory management, quantization, GPU utilization, and batching strategies."
    href="http://vi.developers.datature.com/docs/optimize-performance"
    faIcon="fa-solid fa-gauge-high"
  />
  <BentoCard
    title="Load Models"
    description="Quantization options, device mapping, caching, and loading error handling."
    href="http://vi.developers.datature.com/docs/load-models"
    faIcon="fa-solid fa-download"
  />
  <BentoCard
    title="Prediction Schemas"
    description="Field names and types for VQAResponse, PhraseGroundingResponse, and GenericResponse."
    href="http://vi.developers.datature.com/docs/prediction-schemas"
    faIcon="fa-solid fa-file-code"
  />
</BentoGrid>