{
  "id": 213453,
  "title": "OOM issues using inception_v3 with 299x299 RGB preprocessed images",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/213453",
  "author_name": "",
  "post_date": "2021-01-22T23:43:12.369358800Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Did anyone have OOM issues with images this size? What did you do to fix it?</p>\n<p>Thanks! </p>",
  "messages": [
    {
      "id": "1165390",
      "postDate": "01/22/2021 23:43:12",
      "content": "<p>Did anyone have OOM issues with images this size? What did you do to fix it?</p>\n<p>Thanks! </p>",
      "rawMarkdown": "Did anyone have OOM issues with images this size? What did you do to fix it?\n\nThanks!",
      "votes": null
    },
    {
      "id": "1165454",
      "postDate": "01/23/2021 01:33:43",
      "content": "<p>OOM pretty dependent on the size of the batch your using - so start by cutting the batch size in half.</p>",
      "rawMarkdown": "OOM pretty dependent on the size of the batch your using - so start by cutting the batch size in half.",
      "votes": null
    },
    {
      "id": "1165681",
      "postDate": "01/23/2021 06:58:42",
      "content": "<p>I have encountered OOM several times while experimenting and these are my 2 cents:</p>\n<ul>\n<li>Adjust the batch size first. The best practice is to use <a href=\"https://datascience.stackexchange.com/questions/20179/what-is-the-advantage-of-keeping-batch-size-a-power-of-2\" target=\"_blank\">power of 2</a> or until you need to further reduce it to 1 to fit in memory.</li>\n<li>If it still doesn't fit with batch size = 1, or it takes too long for you, reduce the image size. Caveat: the consensus is 512x512 for image size. Reducing it will probably affect the results substantially.</li>\n<li>Check your augmentation pipeline. Optimizing your code will improve the runtime and memory required.</li>\n<li>As stated by many, larger models doesn't necessarily improve lb/cv. If you browse most notebooks, EfficientNetsB3/B4 are used which are relatively lighter as can be seen on this <a href=\"https://keras.io/api/applications/\" target=\"_blank\">table</a></li>\n</ul>\n<p>Lastly, here's a code to make sure gpu memory clears up if you're looping over models like when using CV:</p>\n<pre><code>from keras import backend as K\nimport gc\ngc.collect()\nK.clear_session()\n</code></pre>",
      "rawMarkdown": "I have encountered OOM several times while experimenting and these are my 2 cents:\n- Adjust the batch size first. The best practice is to use [power of 2](https://datascience.stackexchange.com/questions/20179/what-is-the-advantage-of-keeping-batch-size-a-power-of-2) or until you need to further reduce it to 1 to fit in memory.\n- If it still doesn't fit with batch size = 1, or it takes too long for you, reduce the image size. Caveat: the consensus is 512x512 for image size. Reducing it will probably affect the results substantially.\n- Check your augmentation pipeline. Optimizing your code will improve the runtime and memory required.\n- As stated by many, larger models doesn't necessarily improve lb/cv. If you browse most notebooks, EfficientNetsB3/B4 are used which are relatively lighter as can be seen on this [table](https://keras.io/api/applications/)\n\nLastly, here's a code to make sure gpu memory clears up if you're looping over models like when using CV:\n```\nfrom keras import backend as K\nimport gc\ngc.collect()\nK.clear_session()\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1165454,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "01/23/2021 01:33:43",
      "content": "<p>OOM pretty dependent on the size of the batch your using - so start by cutting the batch size in half.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1165681,
      "author_name": "jasondolorso",
      "author_url": "",
      "post_date": "01/23/2021 06:58:42",
      "content": "<p>I have encountered OOM several times while experimenting and these are my 2 cents:</p>\n<ul>\n<li>Adjust the batch size first. The best practice is to use <a href=\"https://datascience.stackexchange.com/questions/20179/what-is-the-advantage-of-keeping-batch-size-a-power-of-2\" target=\"_blank\">power of 2</a> or until you need to further reduce it to 1 to fit in memory.</li>\n<li>If it still doesn't fit with batch size = 1, or it takes too long for you, reduce the image size. Caveat: the consensus is 512x512 for image size. Reducing it will probably affect the results substantially.</li>\n<li>Check your augmentation pipeline. Optimizing your code will improve the runtime and memory required.</li>\n<li>As stated by many, larger models doesn't necessarily improve lb/cv. If you browse most notebooks, EfficientNetsB3/B4 are used which are relatively lighter as can be seen on this <a href=\"https://keras.io/api/applications/\" target=\"_blank\">table</a></li>\n</ul>\n<p>Lastly, here's a code to make sure gpu memory clears up if you're looping over models like when using CV:</p>\n<pre><code>from keras import backend as K\nimport gc\ngc.collect()\nK.clear_session()\n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1165390": "Did anyone have OOM issues with images this size? What did you do to fix it?\n\nThanks!",
    "1165454": "OOM pretty dependent on the size of the batch your using - so start by cutting the batch size in half.",
    "1165681": "I have encountered OOM several times while experimenting and these are my 2 cents:\n- Adjust the batch size first. The best practice is to use [power of 2](https://datascience.stackexchange.com/questions/20179/what-is-the-advantage-of-keeping-batch-size-a-power-of-2) or until you need to further reduce it to 1 to fit in memory.\n- If it still doesn't fit with batch size = 1, or it takes too long for you, reduce the image size. Caveat: the consensus is 512x512 for image size. Reducing it will probably affect the results substantially.\n- Check your augmentation pipeline. Optimizing your code will improve the runtime and memory required.\n- As stated by many, larger models doesn't necessarily improve lb/cv. If you browse most notebooks, EfficientNetsB3/B4 are used which are relatively lighter as can be seen on this [table](https://keras.io/api/applications/)\n\nLastly, here's a code to make sure gpu memory clears up if you're looping over models like when using CV:\n```\nfrom keras import backend as K\nimport gc\ngc.collect()\nK.clear_session()\n```"
  },
  "source": "meta"
}