{
  "id": 98849,
  "title": "How to debug \"Kernel Threw Exception\" with binary search",
  "url": "/competitions/aptos2019-blindness-detection/discussion/98849",
  "author_name": "higepon",
  "post_date": "2019-07-07T01:25:12.728000",
  "votes": 33,
  "comment_count": 12,
  "views": 0,
  "content": "<p>Hi folks,\nI had a hard time to debug \"Kernel Threw Exception\" when submiting  kernels. As you know there's no additional information in the error. So it's extremely hard to debug it.  Here I'd like to share how I debug my issue with binary search. Hope it helps!</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2199749%2F7432061be194cdc2d7ad4f25db8d230f%2F2019-07-07%2010.08.44.png?generation=1562461744323348&amp;alt=media\" alt=\"\"></p>\n\n<p>First of all,  you should make sure you read all submission error discussions in the Discussion section and double check you're following the right steps.</p>\n\n<p>If you still can't figure out what causes exceptions (like me!), you can use \"try\" to catch the exception and convert the exception to score 0.0.</p>\n\n<p>Say you have 3 sections of suspicious code, you put try and except around the code sections. By doing so if an exception is raised it executes the except block and submit sample_submission.csv which ends up score 0.0.</p>\n\n<p>```\ntry: \n    # suspcious code1 here\n    # suspcious code2 here\n    # suspcious code3 here</p>\n\n<p>except:\n    submission_df = pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n```</p>\n\n<p>See my example code above. If you submit and still see exception, it does mean some code outside of code1, 2 and 3 is throwing the exception.\nIf you see score 0.0, it does mean code1, 2 or 3 is raising the exception. In this case you modify the code, put \"try\" bellow code1 and submit to see if you see 0.0 or exception.  You should be able to use binary search to identify the root cause.</p>\n\n<h2>What was wrong with my code?</h2>\n\n<p>My kernel submission wasn't able to read my dataset named \"aptos-submission\", I just created a new dataset with a random name. Then the exception goes away!</p>\n\n<p>I really hope it helps!</p>",
  "messages": [
    {
      "id": 569581,
      "postDate": "2019-07-07T01:25:12.730Z",
      "content": "<p>Hi folks,\nI had a hard time to debug \"Kernel Threw Exception\" when submiting  kernels. As you know there's no additional information in the error. So it's extremely hard to debug it.  Here I'd like to share how I debug my issue with binary search. Hope it helps!</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2199749%2F7432061be194cdc2d7ad4f25db8d230f%2F2019-07-07%2010.08.44.png?generation=1562461744323348&amp;alt=media\" alt=\"\"></p>\n\n<p>First of all,  you should make sure you read all submission error discussions in the Discussion section and double check you're following the right steps.</p>\n\n<p>If you still can't figure out what causes exceptions (like me!), you can use \"try\" to catch the exception and convert the exception to score 0.0.</p>\n\n<p>Say you have 3 sections of suspicious code, you put try and except around the code sections. By doing so if an exception is raised it executes the except block and submit sample_submission.csv which ends up score 0.0.</p>\n\n<p>```\ntry: \n    # suspcious code1 here\n    # suspcious code2 here\n    # suspcious code3 here</p>\n\n<p>except:\n    submission_df = pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n```</p>\n\n<p>See my example code above. If you submit and still see exception, it does mean some code outside of code1, 2 and 3 is throwing the exception.\nIf you see score 0.0, it does mean code1, 2 or 3 is raising the exception. In this case you modify the code, put \"try\" bellow code1 and submit to see if you see 0.0 or exception.  You should be able to use binary search to identify the root cause.</p>\n\n<h2>What was wrong with my code?</h2>\n\n<p>My kernel submission wasn't able to read my dataset named \"aptos-submission\", I just created a new dataset with a random name. Then the exception goes away!</p>\n\n<p>I really hope it helps!</p>",
      "rawMarkdown": "Hi folks,\nI had a hard time to debug \"Kernel Threw Exception\" when submiting  kernels. As you know there's no additional information in the error. So it's extremely hard to debug it.  Here I'd like to share how I debug my issue with binary search. Hope it helps!\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2199749%2F7432061be194cdc2d7ad4f25db8d230f%2F2019-07-07%2010.08.44.png?generation=1562461744323348&amp;alt=media)\n\nFirst of all,  you should make sure you read all submission error discussions in the Discussion section and double check you're following the right steps.\n\nIf you still can't figure out what causes exceptions (like me!), you can use \"try\" to catch the exception and convert the exception to score 0.0.\n\nSay you have 3 sections of suspicious code, you put try and except around the code sections. By doing so if an exception is raised it executes the except block and submit sample_submission.csv which ends up score 0.0.\n\n```\ntry: \n    # suspcious code1 here\n    # suspcious code2 here\n    # suspcious code3 here\n\nexcept:\n    submission_df = pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n```\n\nSee my example code above. If you submit and still see exception, it does mean some code outside of code1, 2 and 3 is throwing the exception.\nIf you see score 0.0, it does mean code1, 2 or 3 is raising the exception. In this case you modify the code, put \"try\" bellow code1 and submit to see if you see 0.0 or exception.  You should be able to use binary search to identify the root cause.\n\n## What was wrong with my code?\nMy kernel submission wasn't able to read my dataset named \"aptos-submission\", I just created a new dataset with a random name. Then the exception goes away!\n\nI really hope it helps!\n",
      "votes": 33
    },
    {
      "id": 584443,
      "postDate": "2019-07-26T01:35:01.940Z",
      "content": "<p>Can anyone help me, I did what was said up there and found the error here:</p>\n\n<p>```\ntry:\n    sub['diagnosis'] = label</p>\n\n<pre><code>sub.to_csv(\"submission.csv\", index=False)\n</code></pre>\n\n<p>except:\n    submission_df = pd.read_csv('../input/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)</p>\n\n<p>```\nI checked and have the same dimensions, id_code is a string, and diagnosis is numpy.int64.</p>\n\n<p>I have no idea what could be the mistake.</p>",
      "rawMarkdown": "Can anyone help me, I did what was said up there and found the error here:\n\n```\ntry:\n    sub['diagnosis'] = label\n\n    sub.to_csv(\"submission.csv\", index=False)\n\nexcept:\n    submission_df = pd.read_csv('../input/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n\n```\nI checked and have the same dimensions, id_code is a string, and diagnosis is numpy.int64.\n\n\nI have no idea what could be the mistake.",
      "votes": 1
    },
    {
      "id": 571409,
      "postDate": "2019-07-09T15:11:45.210Z",
      "content": "<p>I'm glad to solve what I was worried about\nThanks for sharing!</p>",
      "rawMarkdown": "I'm glad to solve what I was worried about\nThanks for sharing!",
      "votes": 1,
      "replies": [
        {
          "id": 571921,
          "postDate": "2019-07-10T08:34:36.047Z",
          "content": "<p>Sure!</p>",
          "rawMarkdown": "Sure!"
        },
        {
          "id": 574967,
          "postDate": "2019-07-14T19:07:02.243Z",
          "content": "<p>hi dear\nI get totally a different error   status =Submission Error\nNo reason provided. \nHow to debug this totally clueless</p>",
          "rawMarkdown": "hi dear\nI get totally a different error   status =Submission Error\nNo reason provided. \nHow to debug this totally clueless"
        },
        {
          "id": 575083,
          "postDate": "2019-07-15T03:14:52.490Z",
          "content": "<p>Did you check your submission format? number of rows, columns, header and predition type (int not float)?</p>",
          "rawMarkdown": "Did you check your submission format? number of rows, columns, header and predition type (int not float)?"
        }
      ]
    },
    {
      "id": 570685,
      "postDate": "2019-07-08T16:26:30.907Z",
      "content": "<p>I suspect a lot of people could benefit from this, thank you for sharing!</p>",
      "rawMarkdown": "I suspect a lot of people could benefit from this, thank you for sharing!",
      "votes": 2,
      "replies": [
        {
          "id": 571228,
          "postDate": "2019-07-09T10:36:44.360Z",
          "content": "<p>My pleasure!</p>",
          "rawMarkdown": "My pleasure!",
          "votes": 1
        }
      ]
    },
    {
      "id": 619348,
      "postDate": "2019-09-06T05:32:26.843Z",
      "content": "<p><a href=\"/higepon\">@higepon</a>\nhi, can you help me?\nsubmission = pd.DataFrame({'id_code':pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv').id_code.values,\n                          'diagnosis':np.squeeze(preds).astype(int)})\nprint(submission.head())\nsubmission.to_csv('submission.csv', index=False)</p>\n\n<p>kernel threw exception.</p>",
      "rawMarkdown": "@higepon\nhi, can you help me?\nsubmission = pd.DataFrame({'id_code':pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv').id_code.values,\n                          'diagnosis':np.squeeze(preds).astype(int)})\nprint(submission.head())\nsubmission.to_csv('submission.csv', index=False)\n\nkernel threw exception."
    },
    {
      "id": 615457,
      "postDate": "2019-09-02T01:00:49.447Z",
      "content": "<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1133510%2F48193f25c51ebfe0f4382242b971260c%2F2019-09-02%208.45.17.png?generation=1567385159704125&amp;alt=media\" alt=\"\">\nHelp is needed! Does anyone know what is wrong with my kernel? I'm using multi-processing data loader, and 8 processes in this kernel. The kernel runs success, it finishes in 81.6 seconds, but when I submit it to the competition, it seems never to finish. I tried several times, it just says 'Kernel Timeout' when it meets kernel maximum time limitation.</p>",
      "rawMarkdown": "![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1133510%2F48193f25c51ebfe0f4382242b971260c%2F2019-09-02%208.45.17.png?generation=1567385159704125&amp;alt=media)\nHelp is needed! Does anyone know what is wrong with my kernel? I'm using multi-processing data loader, and 8 processes in this kernel. The kernel runs success, it finishes in 81.6 seconds, but when I submit it to the competition, it seems never to finish. I tried several times, it just says 'Kernel Timeout' when it meets kernel maximum time limitation."
    },
    {
      "id": 569586,
      "postDate": "2019-07-07T01:46:21.450Z",
      "content": "<p><a href=\"/higepon\">@higepon</a> \nIt's very usefull :)\nThank you for sharing !</p>",
      "rawMarkdown": "@higepon \nIt's very usefull :)\nThank you for sharing !\n",
      "replies": [
        {
          "id": 569587,
          "postDate": "2019-07-07T01:48:44.560Z",
          "content": "<p>I'm glad I could help!</p>",
          "rawMarkdown": "I'm glad I could help!"
        }
      ]
    },
    {
      "id": 591375,
      "postDate": "2019-08-03T15:37:34.087Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 584443,
      "author_name": "Carlos Eduardo",
      "author_url": "",
      "post_date": "2019-07-26T01:35:01.940000",
      "content": "<p>Can anyone help me, I did what was said up there and found the error here:</p>\n\n<p>```\ntry:\n    sub['diagnosis'] = label</p>\n\n<pre><code>sub.to_csv(\"submission.csv\", index=False)\n</code></pre>\n\n<p>except:\n    submission_df = pd.read_csv('../input/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)</p>\n\n<p>```\nI checked and have the same dimensions, id_code is a string, and diagnosis is numpy.int64.</p>\n\n<p>I have no idea what could be the mistake.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 571409,
      "author_name": "makogarei",
      "author_url": "",
      "post_date": "2019-07-09T15:11:45.210000",
      "content": "<p>I'm glad to solve what I was worried about\nThanks for sharing!</p>",
      "votes": 1,
      "replies": [
        {
          "id": 571921,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2019-07-10T08:34:36.047000",
          "content": "<p>Sure!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 574967,
          "author_name": "Jaideep",
          "author_url": "",
          "post_date": "2019-07-14T19:07:02.243000",
          "content": "<p>hi dear\nI get totally a different error   status =Submission Error\nNo reason provided. \nHow to debug this totally clueless</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 575083,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2019-07-15T03:14:52.490000",
          "content": "<p>Did you check your submission format? number of rows, columns, header and predition type (int not float)?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 570685,
      "author_name": "Sohier Dane",
      "author_url": "",
      "post_date": "2019-07-08T16:26:30.907000",
      "content": "<p>I suspect a lot of people could benefit from this, thank you for sharing!</p>",
      "votes": 2,
      "replies": [
        {
          "id": 571228,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2019-07-09T10:36:44.360000",
          "content": "<p>My pleasure!</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 619348,
      "author_name": "Tahira",
      "author_url": "",
      "post_date": "2019-09-06T05:32:26.843000",
      "content": "<p><a href=\"/higepon\">@higepon</a>\nhi, can you help me?\nsubmission = pd.DataFrame({'id_code':pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv').id_code.values,\n                          'diagnosis':np.squeeze(preds).astype(int)})\nprint(submission.head())\nsubmission.to_csv('submission.csv', index=False)</p>\n\n<p>kernel threw exception.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 615457,
      "author_name": "Jun Liu",
      "author_url": "",
      "post_date": "2019-09-02T01:00:49.447000",
      "content": "<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1133510%2F48193f25c51ebfe0f4382242b971260c%2F2019-09-02%208.45.17.png?generation=1567385159704125&amp;alt=media\" alt=\"\">\nHelp is needed! Does anyone know what is wrong with my kernel? I'm using multi-processing data loader, and 8 processes in this kernel. The kernel runs success, it finishes in 81.6 seconds, but when I submit it to the competition, it seems never to finish. I tried several times, it just says 'Kernel Timeout' when it meets kernel maximum time limitation.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 569586,
      "author_name": "hiro",
      "author_url": "",
      "post_date": "2019-07-07T01:46:21.450000",
      "content": "<p><a href=\"/higepon\">@higepon</a> \nIt's very usefull :)\nThank you for sharing !</p>",
      "votes": 0,
      "replies": [
        {
          "id": 569587,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2019-07-07T01:48:44.560000",
          "content": "<p>I'm glad I could help!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 591375,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-08-03T15:37:34.087000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "569581": "Hi folks,\nI had a hard time to debug \"Kernel Threw Exception\" when submiting  kernels. As you know there's no additional information in the error. So it's extremely hard to debug it.  Here I'd like to share how I debug my issue with binary search. Hope it helps!\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2199749%2F7432061be194cdc2d7ad4f25db8d230f%2F2019-07-07%2010.08.44.png?generation=1562461744323348&amp;alt=media)\n\nFirst of all,  you should make sure you read all submission error discussions in the Discussion section and double check you're following the right steps.\n\nIf you still can't figure out what causes exceptions (like me!), you can use \"try\" to catch the exception and convert the exception to score 0.0.\n\nSay you have 3 sections of suspicious code, you put try and except around the code sections. By doing so if an exception is raised it executes the except block and submit sample_submission.csv which ends up score 0.0.\n\n```\ntry: \n    # suspcious code1 here\n    # suspcious code2 here\n    # suspcious code3 here\n\nexcept:\n    submission_df = pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n```\n\nSee my example code above. If you submit and still see exception, it does mean some code outside of code1, 2 and 3 is throwing the exception.\nIf you see score 0.0, it does mean code1, 2 or 3 is raising the exception. In this case you modify the code, put \"try\" bellow code1 and submit to see if you see 0.0 or exception.  You should be able to use binary search to identify the root cause.\n\n## What was wrong with my code?\nMy kernel submission wasn't able to read my dataset named \"aptos-submission\", I just created a new dataset with a random name. Then the exception goes away!\n\nI really hope it helps!\n",
    "584443": "Can anyone help me, I did what was said up there and found the error here:\n\n```\ntry:\n    sub['diagnosis'] = label\n\n    sub.to_csv(\"submission.csv\", index=False)\n\nexcept:\n    submission_df = pd.read_csv('../input/sample_submission.csv')\n    submission_df.to_csv('submission.csv', index=False)\n\n```\nI checked and have the same dimensions, id_code is a string, and diagnosis is numpy.int64.\n\n\nI have no idea what could be the mistake.",
    "571409": "I'm glad to solve what I was worried about\nThanks for sharing!",
    "570685": "I suspect a lot of people could benefit from this, thank you for sharing!",
    "619348": "@higepon\nhi, can you help me?\nsubmission = pd.DataFrame({'id_code':pd.read_csv('../input/aptos2019-blindness-detection/sample_submission.csv').id_code.values,\n                          'diagnosis':np.squeeze(preds).astype(int)})\nprint(submission.head())\nsubmission.to_csv('submission.csv', index=False)\n\nkernel threw exception.",
    "615457": "![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1133510%2F48193f25c51ebfe0f4382242b971260c%2F2019-09-02%208.45.17.png?generation=1567385159704125&amp;alt=media)\nHelp is needed! Does anyone know what is wrong with my kernel? I'm using multi-processing data loader, and 8 processes in this kernel. The kernel runs success, it finishes in 81.6 seconds, but when I submit it to the competition, it seems never to finish. I tried several times, it just says 'Kernel Timeout' when it meets kernel maximum time limitation.",
    "569586": "@higepon \nIt's very usefull :)\nThank you for sharing !\n",
    "591375": ""
  }
}