{
  "id": 156303,
  "title": "GPU makes no difference",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/156303",
  "author_name": "",
  "post_date": "2020-06-05T11:42:35.233475500Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I can't see a difference between CPU and GPU running times. Where is the mistake?</p>\n\n<p>This is my kernel: kaggle.com/fredericods/melanoma-classification/</p>\n\n<p>Thanks!</p>",
  "messages": [
    {
      "id": "874951",
      "postDate": "06/05/2020 11:42:35",
      "content": "<p>I can't see a difference between CPU and GPU running times. Where is the mistake?</p>\n\n<p>This is my kernel: kaggle.com/fredericods/melanoma-classification/</p>\n\n<p>Thanks!</p>",
      "rawMarkdown": "I can't see a difference between CPU and GPU running times. Where is the mistake?\n\nThis is my kernel: kaggle.com/fredericods/melanoma-classification/\n\nThanks!",
      "votes": null
    },
    {
      "id": "874973",
      "postDate": "06/05/2020 12:14:40",
      "content": "<p>Specify strategy similar to other public kernels.</p>\n\n<p><code>\nstrategy = tf.distribute.get_strategy()\nwith strategy.scope():\n    ...\n</code></p>",
      "rawMarkdown": "Specify strategy similar to other public kernels.\n\n```\nstrategy = tf.distribute.get_strategy()\nwith strategy.scope():\n    ...\n```",
      "votes": null
    },
    {
      "id": "875123",
      "postDate": "06/05/2020 14:38:58",
      "content": "<p>During each epoch, you read 33,000 images from the disk and resize them from 1024x1024 to 96x96. It would be faster if first you resize all the images to 96x96 and save them to a Kaggle dataset. Then during training, just read in those 96x96 images and you don't have to spend time resizing them.</p>\n\n<p>It will be faster since you are reading smaller files from disk and not spending time resizing.</p>",
      "rawMarkdown": "During each epoch, you read 33,000 images from the disk and resize them from 1024x1024 to 96x96. It would be faster if first you resize all the images to 96x96 and save them to a Kaggle dataset. Then during training, just read in those 96x96 images and you don't have to spend time resizing them.\n\nIt will be faster since you are reading smaller files from disk and not spending time resizing.",
      "votes": null
    },
    {
      "id": "875150",
      "postDate": "06/05/2020 14:51:49",
      "content": "<p>Oh, there is a bottleneck while reading image files...</p>\n\n<p>I'm going to try this. Thank very much for the response, Chris!</p>",
      "rawMarkdown": "Oh, there is a bottleneck while reading image files...\n\nI'm going to try this. Thank very much for the response, Chris!",
      "votes": null
    },
    {
      "id": "875161",
      "postDate": "06/05/2020 14:58:08",
      "content": "<p>Let me know if that speeds things up. If not, I would next suggest loading all the images into RAM. Since you are using the small size of 96x96, then 33000 images should only take <code>3.7GB = 96x96x3x4x33000</code>. So you could put all the images into a NumPy array and train from the NumPy array.</p>\n\n<p>That would be faster because reading from RAM is much faster than reading from Disk.</p>\n\n<p>(But either way, you should resample all 1024x1024 to 96x96 and save that to a new dataset, so whatever you do afterwards only has to read 96x96 off disk).</p>",
      "rawMarkdown": "Let me know if that speeds things up. If not, I would next suggest loading all the images into RAM. Since you are using the small size of 96x96, then 33000 images should only take `3.7GB = 96x96x3x4x33000`. So you could put all the images into a NumPy array and train from the NumPy array.\n\nThat would be faster because reading from RAM is much faster than reading from Disk.\n\n(But either way, you should resample all 1024x1024 to 96x96 and save that to a new dataset, so whatever you do afterwards only has to read 96x96 off disk).",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 874973,
      "author_name": "sirishks",
      "author_url": "",
      "post_date": "06/05/2020 12:14:40",
      "content": "<p>Specify strategy similar to other public kernels.</p>\n\n<p><code>\nstrategy = tf.distribute.get_strategy()\nwith strategy.scope():\n    ...\n</code></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 875123,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "06/05/2020 14:38:58",
      "content": "<p>During each epoch, you read 33,000 images from the disk and resize them from 1024x1024 to 96x96. It would be faster if first you resize all the images to 96x96 and save them to a Kaggle dataset. Then during training, just read in those 96x96 images and you don't have to spend time resizing them.</p>\n\n<p>It will be faster since you are reading smaller files from disk and not spending time resizing.</p>",
      "votes": null,
      "replies": [
        {
          "id": 875150,
          "author_name": "fredericods",
          "author_url": "",
          "post_date": "06/05/2020 14:51:49",
          "content": "<p>Oh, there is a bottleneck while reading image files...</p>\n\n<p>I'm going to try this. Thank very much for the response, Chris!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 875161,
          "author_name": "cdeotte",
          "author_url": "",
          "post_date": "06/05/2020 14:58:08",
          "content": "<p>Let me know if that speeds things up. If not, I would next suggest loading all the images into RAM. Since you are using the small size of 96x96, then 33000 images should only take <code>3.7GB = 96x96x3x4x33000</code>. So you could put all the images into a NumPy array and train from the NumPy array.</p>\n\n<p>That would be faster because reading from RAM is much faster than reading from Disk.</p>\n\n<p>(But either way, you should resample all 1024x1024 to 96x96 and save that to a new dataset, so whatever you do afterwards only has to read 96x96 off disk).</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "874951": "I can't see a difference between CPU and GPU running times. Where is the mistake?\n\nThis is my kernel: kaggle.com/fredericods/melanoma-classification/\n\nThanks!",
    "874973": "Specify strategy similar to other public kernels.\n\n```\nstrategy = tf.distribute.get_strategy()\nwith strategy.scope():\n    ...\n```",
    "875123": "During each epoch, you read 33,000 images from the disk and resize them from 1024x1024 to 96x96. It would be faster if first you resize all the images to 96x96 and save them to a Kaggle dataset. Then during training, just read in those 96x96 images and you don't have to spend time resizing them.\n\nIt will be faster since you are reading smaller files from disk and not spending time resizing.",
    "875150": "Oh, there is a bottleneck while reading image files...\n\nI'm going to try this. Thank very much for the response, Chris!",
    "875161": "Let me know if that speeds things up. If not, I would next suggest loading all the images into RAM. Since you are using the small size of 96x96, then 33000 images should only take `3.7GB = 96x96x3x4x33000`. So you could put all the images into a NumPy array and train from the NumPy array.\n\nThat would be faster because reading from RAM is much faster than reading from Disk.\n\n(But either way, you should resample all 1024x1024 to 96x96 and save that to a new dataset, so whatever you do afterwards only has to read 96x96 off disk)."
  },
  "source": "meta"
}