MetaX-Tech Developer Forum 论坛首页
  • 沐曦开发者
search
Sign in

justinniu

  • Members
  • Joined 2026年8月5日
  • message 帖子
  • forum 主题
  • favorite 关注者
  • favorite_border Follows
  • person_outline 详细信息

justinniu has started 1 thread.

  • See post chevron_right
    justinniu
    Members
    沐曦C550,用 MacaRT C++ API 加载Onnx模型失败,卡在创建Session 已解决 2026年8月5日 16:31

    一、软硬件信息
    1.服务器厂家:
    2.沐曦GPU型号:C550
    3.操作系统内核版本:5.14.0-3.1.8.kwai.x86_64
    4.是否开启CPU虚拟化:是
    5.mx-smi回显:

    Quoted message:

    mx-smi version: 2.2.9

    =================== MetaX System Management Interface Log ===================
    Timestamp : Wed Aug 5 16:33:27 2026

    Attached GPUs : 1
    +---------------------------------------------------------------------------------+
    | MX-SMI 2.2.9 Kernel Mode Driver Version: 3.4.3 |
    | MACA Version: 3.3.2.27 BIOS Version: 1.30.0.0 |
    |------------------+-----------------+---------------------+----------------------|
    | Board Name | GPU Persist-M | Bus-id | GPU-Util sGPU-M |
    | Pwr:Usage/Cap | Temp Perf | Memory-Usage | GPU-State |
    |==================+=================+=====================+======================|
    | 0 MetaX C550 | 0 Off | 0000:c2:00.0 | 0% Disabled |
    | 91W / 450W | 33C P0 | 858/65536 MiB | Available |
    +------------------+-----------------+---------------------+----------------------+

    +---------------------------------------------------------------------------------+
    | Process: |
    | GPU PID Process Name GPU Memory |
    | Usage(MiB) |
    |=================================================================================|
    | no process found |
    +---------------------------------------------------------------------------------+

    End of Log

    二、问题现象
    请描述详细的问题现象日志。若日志过长,请上传附件(txt格式)。

    代码 has written:

    bool MxOnnxRuntimeBackend::Init(const ModelConfig& config) {
    CleanupRuntimeResources();
    config_ = config;
    initialized_ = false;

    options_ = MxRuntimeOptions();
    options_.device_id = ReadEnvInt("MX_DEVICE_ID", 0, 0, INT_MAX);
    
    std::string model_path = config_.LocalPath;
    if (!model_path.empty() && model_path.front() != '/') {
        model_path = BuildRelativePath(model_path);
    }
    if (model_path.empty()) {
        LOG(ERROR) << LogPrefix("init:1/4") << " empty model path";
        return false;
    }
    LOG(INFO) << LogPrefix("init:1/4") << " LOAD-ONLY build (no warmup, no inference)"
              << " path=" << model_path
              << " MX_DEVICE_ID=" << options_.device_id;
    
    try {
        LOG(INFO) << LogPrefix("init:2/4") << " acquiring shared Ort::Env";
        Ort::Env& env = SharedOrtEnv();
    
        // The documented minimum: name the device through the provider options
        // and let MacaEP do the rest. DisableMemPattern and ORT_DISABLE_ALL are
        // kept from the vendor sample because that configuration is known to
        // load successfully.
        Ort::SessionOptions session_options;
        OrtMACAProviderOptions maca_options;
        maca_options.device_id = options_.device_id;
        maca_options.maca_graph_switch = 0;
        session_options.AppendExecutionProvider_MACA(maca_options);
        session_options.DisableMemPattern();
        session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_DISABLE_ALL);
        LOG(INFO) << LogPrefix("init:2/4") << " SessionOptions ready"
                  << " device_id=" << maca_options.device_id;
    
        LOG(INFO) << LogPrefix("init:3/4") << " creating Ort::Session ..."
                  << " (if this is the last line, session creation hung or crashed)";
        const auto begin = std::chrono::steady_clock::now();
        session_ = std::make_unique<Ort::Session>(env, model_path.c_str(), session_options);
        const auto end = std::chrono::steady_clock::now();
        LOG(INFO) << LogPrefix("init:3/4") << " Ort::Session created in "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count()
                  << " ms";
    
        LogModelIo();
    
        initialized_ = true;
        LOG(INFO) << LogPrefix("init:done") << " model loaded"
                  << " inputs=" << input_names_.size()
                  << " outputs=" << output_names_.size()
                  << " device_id=" << options_.device_id;
        return true;
    } catch (const Ort::Exception& error) {
        LOG(ERROR) << LogPrefix("init:failed") << " ORT exception loading " << model_path
                   << " code=" << error.GetOrtErrorCode() << ": " << error.what();
    } catch (const std::exception& error) {
        LOG(ERROR) << LogPrefix("init:failed") << " exception loading " << model_path
                   << ": " << error.what();
    }
    CleanupRuntimeResources();
    return false;
    

    }

  • 沐曦开发者论坛
powered by misago