{
  "id": 377830,
  "title": "Running out of RAM on submission... what's using my CPU RAM?",
  "url": "/competitions/rsna-breast-cancer-detection/discussion/377830",
  "author_name": "Ben Lebovitz",
  "post_date": "2023-01-13T03:45:30.576000",
  "votes": 2,
  "comment_count": 3,
  "views": 0,
  "content": "<p><a href=\"https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook\" target=\"_blank\">https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook</a></p>\n<p>In the above notebook, I put a pipeline together based on </p>\n<ol>\n<li><a href=\"https://www.kaggle.com/code/theoviel/dicom-resized-png-jpg\" target=\"_blank\">this notebook </a>by <a href=\"https://www.kaggle.com/theoviel\" target=\"_blank\">@theoviel</a> to quickly extract PNGs. </li>\n<li><a href=\"https://www.kaggle.com/code/remekkinas/breast-cancer-roi-brest-extractor\" target=\"_blank\">And this notebook</a> by <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a> </li>\n</ol>\n<p>It works well with the whole training set of 54k DICOM images… Takes about 4 hours to run.</p>\n<p>But… when trying to get it to submit to the contest, I get an out of memory error and I'm not sure how to fix it.</p>\n<p>I spent most of today trying to figure out how to release RAM between different stages of the notebook. Using training data… after it's done changing to PNG files, but before doing the ROI processing, the notebook says that it's using ~10GB of CPU RAM at that time (and very little GPU). </p>\n<p>At that point I can delete everything except for the extracted PNGs that are in a temp folder.</p>\n<p>But doing %whos and deleting a bunch of vars and doing 'gc.collect()' didn't get me anywhere, the CPU RAM usage didn't budge at all. GPU RAM is low at that point.</p>\n<p>I can't figure out what's using all the RAM…</p>\n<p>Thanks in advance for the help,<br>\nBen</p>",
  "messages": [
    {
      "id": 2097967,
      "postDate": "2023-01-13T05:42:51.763Z",
      "content": "<p>Check this line before finishing notebook (I have it before resulting_df.to_csv('submission.csv', index=True)</p>\n<pre><code>!rm -r roi_cropped\n</code></pre>\n<p>I had such problem defore cleaning mess in my working dir. </p>\n<p>One more thing (I have not analyzed all notebook) -&gt; submission.csv column should be cancer not cancer_x.</p>",
      "rawMarkdown": "Check this line before finishing notebook (I have it before resulting_df.to_csv('submission.csv', index=True)\n\n```\n!rm -r roi_cropped\n```\n\nI had such problem defore cleaning mess in my working dir. \n\nOne more thing (I have not analyzed all notebook) -> submission.csv column should be cancer not cancer_x.",
      "votes": 1,
      "replies": [
        {
          "id": 2098194,
          "postDate": "2023-01-13T09:59:11.530Z",
          "content": "<p>Thanks, added the line. I just set it to run and, so I guess I'll cross my fingers and go back to bed (it's very early in NY, but I was dreaming of kaggle so figured I'd get up and work on it…) Although I'm skeptical as I'm not getting the \"can't find submission.csv\" error, but rather the error that I ran out of RAM.</p>\n<p>It's only cancer_x in the training. I had some minor issues when pd.merging and wrote a little conditional to handle it. I'll clean that up though to make it less confusing for anyone who looks at it later.</p>\n<pre><code>if DEBUG: resulting_df = merged_df[['prediction_id', 'cancer_x']]\nelse: resulting_df = merged_df[['prediction_id', 'cancer']]\n</code></pre>\n<p>Thanks again for helping!</p>",
          "rawMarkdown": "Thanks, added the line. I just set it to run and, so I guess I'll cross my fingers and go back to bed (it's very early in NY, but I was dreaming of kaggle so figured I'd get up and work on it...) Although I'm skeptical as I'm not getting the \"can't find submission.csv\" error, but rather the error that I ran out of RAM.\n\nIt's only cancer_x in the training. I had some minor issues when pd.merging and wrote a little conditional to handle it. I'll clean that up though to make it less confusing for anyone who looks at it later.\n\n```\nif DEBUG: resulting_df = merged_df[['prediction_id', 'cancer_x']]\nelse: resulting_df = merged_df[['prediction_id', 'cancer']]\n```\n\nThanks again for helping!",
          "votes": 1
        },
        {
          "id": 2098374,
          "postDate": "2023-01-13T13:31:49.803Z",
          "content": "<p>Yeah, ran out of memory….</p>",
          "rawMarkdown": "Yeah, ran out of memory...."
        }
      ]
    },
    {
      "id": 2097903,
      "postDate": "2023-01-13T03:45:30.577Z",
      "content": "<p><a href=\"https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook\" target=\"_blank\">https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook</a></p>\n<p>In the above notebook, I put a pipeline together based on </p>\n<ol>\n<li><a href=\"https://www.kaggle.com/code/theoviel/dicom-resized-png-jpg\" target=\"_blank\">this notebook </a>by <a href=\"https://www.kaggle.com/theoviel\" target=\"_blank\">@theoviel</a> to quickly extract PNGs. </li>\n<li><a href=\"https://www.kaggle.com/code/remekkinas/breast-cancer-roi-brest-extractor\" target=\"_blank\">And this notebook</a> by <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a> </li>\n</ol>\n<p>It works well with the whole training set of 54k DICOM images… Takes about 4 hours to run.</p>\n<p>But… when trying to get it to submit to the contest, I get an out of memory error and I'm not sure how to fix it.</p>\n<p>I spent most of today trying to figure out how to release RAM between different stages of the notebook. Using training data… after it's done changing to PNG files, but before doing the ROI processing, the notebook says that it's using ~10GB of CPU RAM at that time (and very little GPU). </p>\n<p>At that point I can delete everything except for the extracted PNGs that are in a temp folder.</p>\n<p>But doing %whos and deleting a bunch of vars and doing 'gc.collect()' didn't get me anywhere, the CPU RAM usage didn't budge at all. GPU RAM is low at that point.</p>\n<p>I can't figure out what's using all the RAM…</p>\n<p>Thanks in advance for the help,<br>\nBen</p>",
      "rawMarkdown": "https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook\n\nIn the above notebook, I put a pipeline together based on \n1.  [this notebook ](https://www.kaggle.com/code/theoviel/dicom-resized-png-jpg)by @theoviel to quickly extract PNGs. \n2. [And this notebook](https://www.kaggle.com/code/remekkinas/breast-cancer-roi-brest-extractor) by @remekkinas \n\nIt works well with the whole training set of 54k DICOM images... Takes about 4 hours to run.\n\nBut... when trying to get it to submit to the contest, I get an out of memory error and I'm not sure how to fix it.\n\nI spent most of today trying to figure out how to release RAM between different stages of the notebook. Using training data... after it's done changing to PNG files, but before doing the ROI processing, the notebook says that it's using ~10GB of CPU RAM at that time (and very little GPU). \n\nAt that point I can delete everything except for the extracted PNGs that are in a temp folder.\n\nBut doing %whos and deleting a bunch of vars and doing 'gc.collect()' didn't get me anywhere, the CPU RAM usage didn't budge at all. GPU RAM is low at that point.\n\nI can't figure out what's using all the RAM...\n\n\nThanks in advance for the help,\nBen",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 2097967,
      "author_name": "Remek Kinas",
      "author_url": "",
      "post_date": "2023-01-13T05:42:51.763000",
      "content": "<p>Check this line before finishing notebook (I have it before resulting_df.to_csv('submission.csv', index=True)</p>\n<pre><code>!rm -r roi_cropped\n</code></pre>\n<p>I had such problem defore cleaning mess in my working dir. </p>\n<p>One more thing (I have not analyzed all notebook) -&gt; submission.csv column should be cancer not cancer_x.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2098194,
          "author_name": "Ben Lebovitz",
          "author_url": "",
          "post_date": "2023-01-13T09:59:11.530000",
          "content": "<p>Thanks, added the line. I just set it to run and, so I guess I'll cross my fingers and go back to bed (it's very early in NY, but I was dreaming of kaggle so figured I'd get up and work on it…) Although I'm skeptical as I'm not getting the \"can't find submission.csv\" error, but rather the error that I ran out of RAM.</p>\n<p>It's only cancer_x in the training. I had some minor issues when pd.merging and wrote a little conditional to handle it. I'll clean that up though to make it less confusing for anyone who looks at it later.</p>\n<pre><code>if DEBUG: resulting_df = merged_df[['prediction_id', 'cancer_x']]\nelse: resulting_df = merged_df[['prediction_id', 'cancer']]\n</code></pre>\n<p>Thanks again for helping!</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2098374,
          "author_name": "Ben Lebovitz",
          "author_url": "",
          "post_date": "2023-01-13T13:31:49.803000",
          "content": "<p>Yeah, ran out of memory….</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2097967": "Check this line before finishing notebook (I have it before resulting_df.to_csv('submission.csv', index=True)\n\n```\n!rm -r roi_cropped\n```\n\nI had such problem defore cleaning mess in my working dir. \n\nOne more thing (I have not analyzed all notebook) -> submission.csv column should be cancer not cancer_x.",
    "2097903": "https://www.kaggle.com/code/beezus666/dicom-to-png-to-roi-png/notebook\n\nIn the above notebook, I put a pipeline together based on \n1.  [this notebook ](https://www.kaggle.com/code/theoviel/dicom-resized-png-jpg)by @theoviel to quickly extract PNGs. \n2. [And this notebook](https://www.kaggle.com/code/remekkinas/breast-cancer-roi-brest-extractor) by @remekkinas \n\nIt works well with the whole training set of 54k DICOM images... Takes about 4 hours to run.\n\nBut... when trying to get it to submit to the contest, I get an out of memory error and I'm not sure how to fix it.\n\nI spent most of today trying to figure out how to release RAM between different stages of the notebook. Using training data... after it's done changing to PNG files, but before doing the ROI processing, the notebook says that it's using ~10GB of CPU RAM at that time (and very little GPU). \n\nAt that point I can delete everything except for the extracted PNGs that are in a temp folder.\n\nBut doing %whos and deleting a bunch of vars and doing 'gc.collect()' didn't get me anywhere, the CPU RAM usage didn't budge at all. GPU RAM is low at that point.\n\nI can't figure out what's using all the RAM...\n\n\nThanks in advance for the help,\nBen"
  }
}