mudler/LocalAI · error

2

2

Error message

[sam3-cpp] Failed to create state\n

What it means

sam3-cpp failed to create its inference state after loading. Guard: treat state creation failure as fatal to LoadModel, free the loaded model, and report the failure instead of continuing with a null state.

Source

Thrown at backend/go/sam3-cpp/cpp/gosam3.cpp:57

}

extern "C" {

int sam3_cpp_load_model(const char *model_path, int threads) {
    sam3_params params;
    params.model_path = model_path;
    params.n_threads = threads;
    params.use_gpu = true;

    g_model = sam3_load_model(params);
    if (!g_model) {
        fprintf(stderr, "[sam3-cpp] Failed to load model: %s\n", model_path);
        return 1;
    }

    g_state = sam3_create_state(*g_model, params);
    if (!g_state) {
        fprintf(stderr, "[sam3-cpp] Failed to create state\n");
        g_model.reset();
        return 2;
    }

    fprintf(stderr, "[sam3-cpp] Model loaded: %s (threads=%d)\n", model_path, threads);
    return 0;
}

int sam3_cpp_encode_image(const char *image_path) {
    if (!g_model || !g_state) {
        fprintf(stderr, "[sam3-cpp] Model not loaded\n");
        return 1;
    }

    sam3_image img = sam3_load_image(image_path);
    if (img.data.empty()) {
        fprintf(stderr, "[sam3-cpp] Failed to load image: %s\n", image_path);
        return 2;

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Ensure the model was loaded successfully before creating state; check earlier load errors.
  2. Verify sufficient memory is available to allocate the SAM 3 state.

When it happens

Trigger: Thrown at backend/go/sam3-cpp/cpp/gosam3.cpp:57 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/170bba6963129140. Report an issue: GitHub.