{
  "id": 599676,
  "title": "SERVER_RAISED_EXCEPTION but with an empty error message",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/599676",
  "author_name": "",
  "post_date": "2025-08-18T06:01:07.417184100Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<h1>Problem Description</h1>\n<p>I'm facing an issue with the inference server for the CMI Challenge. When running predictions using CMIInferenceServer, I encounter the following problem:</p>\n<p>The first prediction works correctly<br>\nSubsequent predictions fail with a GatewayRuntimeError with type SERVER_RAISED_EXCEPTION but with an empty error message<br>\nThis makes debugging difficult since there's no meaningful error output to troubleshoot.</p>\n<h1>My Current Implementation</h1>\n<p>`<br>\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -&gt; str:<br>\n    sequence = sequence.to_pandas()<br>\n    demographics = demographics.to_pandas()<br>\n    # Preprocess the input data<br>\n    acc_data, gyr_data, thrm_data, tof_data, num_chunks = process_sequence(sequence)</p>\n<pre><code>num_chunks = torch.tensor(num_chunks).unsqueeze(0)\nacc_data = torch.tensor(acc_data, =torch.float32).unsqueeze(0)  #  batch dimension\ngyr_data = torch.tensor(gyr_data, =torch.float32).unsqueeze(0)  #  batch dimension\nthrm_data = torch.tensor(thrm_data, =torch.float32).unsqueeze(0)  #  batch dimension\ntof_data = torch.tensor(tof_data, =torch.float32).unsqueeze(0)  #  batch dimension\n\nmodel.eval()  #  the model  evaluation mode\n\nwith torch.no_grad():\n    acc_data = acc_data.(device)\n    gyr_data = gyr_data.(device)\n    thrm_data = thrm_data.(device)\n    tof_data = tof_data.(device)\n    predictions = model(num_chunks, acc_data, gyr_data, thrm_data, tof_data)\n\npredictions = predictions.argmax(=1).detach().cpu().numpy()\npredicted_classes = target_encoder.inverse_transform(predictions)[0]\n\n(predicted_classes)\n\nreturn predicted_classes\n</code></pre>\n<p>`</p>",
  "messages": [
    {
      "id": "3271121",
      "postDate": "08/18/2025 06:01:07",
      "content": "<h1>Problem Description</h1>\n<p>I'm facing an issue with the inference server for the CMI Challenge. When running predictions using CMIInferenceServer, I encounter the following problem:</p>\n<p>The first prediction works correctly<br>\nSubsequent predictions fail with a GatewayRuntimeError with type SERVER_RAISED_EXCEPTION but with an empty error message<br>\nThis makes debugging difficult since there's no meaningful error output to troubleshoot.</p>\n<h1>My Current Implementation</h1>\n<p>`<br>\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -&gt; str:<br>\n    sequence = sequence.to_pandas()<br>\n    demographics = demographics.to_pandas()<br>\n    # Preprocess the input data<br>\n    acc_data, gyr_data, thrm_data, tof_data, num_chunks = process_sequence(sequence)</p>\n<pre><code>num_chunks = torch.tensor(num_chunks).unsqueeze(0)\nacc_data = torch.tensor(acc_data, =torch.float32).unsqueeze(0)  #  batch dimension\ngyr_data = torch.tensor(gyr_data, =torch.float32).unsqueeze(0)  #  batch dimension\nthrm_data = torch.tensor(thrm_data, =torch.float32).unsqueeze(0)  #  batch dimension\ntof_data = torch.tensor(tof_data, =torch.float32).unsqueeze(0)  #  batch dimension\n\nmodel.eval()  #  the model  evaluation mode\n\nwith torch.no_grad():\n    acc_data = acc_data.(device)\n    gyr_data = gyr_data.(device)\n    thrm_data = thrm_data.(device)\n    tof_data = tof_data.(device)\n    predictions = model(num_chunks, acc_data, gyr_data, thrm_data, tof_data)\n\npredictions = predictions.argmax(=1).detach().cpu().numpy()\npredicted_classes = target_encoder.inverse_transform(predictions)[0]\n\n(predicted_classes)\n\nreturn predicted_classes\n</code></pre>\n<p>`</p>",
      "rawMarkdown": "# Problem Description\nI'm facing an issue with the inference server for the CMI Challenge. When running predictions using CMIInferenceServer, I encounter the following problem:\n\nThe first prediction works correctly\nSubsequent predictions fail with a GatewayRuntimeError with type SERVER_RAISED_EXCEPTION but with an empty error message\nThis makes debugging difficult since there's no meaningful error output to troubleshoot.\n\n# My Current Implementation\n\n`\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -> str:\n    sequence = sequence.to_pandas()\n    demographics = demographics.to_pandas()\n    # Preprocess the input data\n    acc_data, gyr_data, thrm_data, tof_data, num_chunks = process_sequence(sequence)\n    \n  \n    num_chunks = torch.tensor(num_chunks).unsqueeze(0)\n    acc_data = torch.tensor(acc_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    gyr_data = torch.tensor(gyr_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    thrm_data = torch.tensor(thrm_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    tof_data = torch.tensor(tof_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n\n    model.eval()  # Set the model to evaluation mode\n    # Forward pass through the model\n    with torch.no_grad():\n        acc_data = acc_data.to(device)\n        gyr_data = gyr_data.to(device)\n        thrm_data = thrm_data.to(device)\n        tof_data = tof_data.to(device)\n        predictions = model(num_chunks, acc_data, gyr_data, thrm_data, tof_data)\n\n    predictions = predictions.argmax(dim=1).detach().cpu().numpy()\n    predicted_classes = target_encoder.inverse_transform(predictions)[0]\n\n    print(predicted_classes)\n\n    return predicted_classes\n`",
      "votes": null
    },
    {
      "id": "3271762",
      "postDate": "08/19/2025 15:40:43",
      "content": "<p>I had the same issue; check the result type of your model; it should be str not numpy.str_ as it was for me or something else.<br>\nConverting from numpy_str_ to str for me resolved the problem.</p>",
      "rawMarkdown": "I had the same issue; check the result type of your model; it should be str not numpy.str_ as it was for me or something else.\nConverting from numpy_str_ to str for me resolved the problem.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3271762,
      "author_name": "obiaf88",
      "author_url": "",
      "post_date": "08/19/2025 15:40:43",
      "content": "<p>I had the same issue; check the result type of your model; it should be str not numpy.str_ as it was for me or something else.<br>\nConverting from numpy_str_ to str for me resolved the problem.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3271121": "# Problem Description\nI'm facing an issue with the inference server for the CMI Challenge. When running predictions using CMIInferenceServer, I encounter the following problem:\n\nThe first prediction works correctly\nSubsequent predictions fail with a GatewayRuntimeError with type SERVER_RAISED_EXCEPTION but with an empty error message\nThis makes debugging difficult since there's no meaningful error output to troubleshoot.\n\n# My Current Implementation\n\n`\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -> str:\n    sequence = sequence.to_pandas()\n    demographics = demographics.to_pandas()\n    # Preprocess the input data\n    acc_data, gyr_data, thrm_data, tof_data, num_chunks = process_sequence(sequence)\n    \n  \n    num_chunks = torch.tensor(num_chunks).unsqueeze(0)\n    acc_data = torch.tensor(acc_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    gyr_data = torch.tensor(gyr_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    thrm_data = torch.tensor(thrm_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n    tof_data = torch.tensor(tof_data, dtype=torch.float32).unsqueeze(0)  # Add batch dimension\n\n    model.eval()  # Set the model to evaluation mode\n    # Forward pass through the model\n    with torch.no_grad():\n        acc_data = acc_data.to(device)\n        gyr_data = gyr_data.to(device)\n        thrm_data = thrm_data.to(device)\n        tof_data = tof_data.to(device)\n        predictions = model(num_chunks, acc_data, gyr_data, thrm_data, tof_data)\n\n    predictions = predictions.argmax(dim=1).detach().cpu().numpy()\n    predicted_classes = target_encoder.inverse_transform(predictions)[0]\n\n    print(predicted_classes)\n\n    return predicted_classes\n`",
    "3271762": "I had the same issue; check the result type of your model; it should be str not numpy.str_ as it was for me or something else.\nConverting from numpy_str_ to str for me resolved the problem."
  },
  "source": "meta"
}