{
  "id": 166800,
  "title": "Faster Augmentations on CPU while GPU trains",
  "url": "/competitions/tpu-getting-started/discussion/166800",
  "author_name": "nEO",
  "post_date": "2020-07-14T03:56:28.421000",
  "votes": 0,
  "comment_count": 3,
  "views": null,
  "content": "<p>Hi All, </p>\n\n<p>I read multiple places where the augmentations can be sped up by making the CPU prepare the next batch while the GPU trains on the data and does all the cool stuff.</p>\n\n<p>However, I couldn't find any documentation/ code about it. If there is something that can be shared here, I'd really appreciate it. Thank you.</p>",
  "messages": [
    {
      "id": 1112797,
      "postDate": "2020-12-14T22:36:18.977Z",
      "content": "<p>Hi,<br>\ncheck out the following link about data augmentation in TF<br>\n<a href=\"https://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3\" target=\"_blank\">https://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3</a></p>",
      "rawMarkdown": "Hi,\ncheck out the following link about data augmentation in TF\nhttps://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3"
    },
    {
      "id": 928686,
      "postDate": "2020-07-14T06:43:20.207Z",
      "content": "<p>I think I found my answer. Looking at this notebook\n<a href=\"https://www.kaggle.com/nitindatta/flower-classification-augmentations-eda\">https://www.kaggle.com/nitindatta/flower-classification-augmentations-eda</a></p>\n\n<p>and the following documentation on Tensorflow's website gave me many of the answers I was looking for\n<a href=\"https://www.tensorflow.org/guide/data_performance\">https://www.tensorflow.org/guide/data_performance</a>\n<a href=\"https://www.tensorflow.org/tutorials/images/data_augmentation\">https://www.tensorflow.org/tutorials/images/data_augmentation</a></p>\n\n<p>Hopefully if someone else was looking for these answers finds this post useful.</p>",
      "rawMarkdown": "I think I found my answer. Looking at this notebook\nhttps://www.kaggle.com/nitindatta/flower-classification-augmentations-eda\n\nand the following documentation on Tensorflow's website gave me many of the answers I was looking for\nhttps://www.tensorflow.org/guide/data_performance\nhttps://www.tensorflow.org/tutorials/images/data_augmentation\n\nHopefully if someone else was looking for these answers finds this post useful.",
      "replies": [
        {
          "id": 952797,
          "postDate": "2020-07-31T08:25:06.317Z",
          "content": "<p>Please note that the trick above (in the notebook you cited) actually does augmentation on GPU, not CPU. A more detailed explanation in this kernel: <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96</a></p>\n\n<p>This will make sense only if you have a slow CPU (e.g. a free one in online kernels). Ideally, if you have a custom rig, your CPU should be fast enough to process images faster than the GPU can consume them (GPU resources shouldn't be wasted on augmentations).</p>",
          "rawMarkdown": "Please note that the trick above (in the notebook you cited) actually does augmentation on GPU, not CPU. A more detailed explanation in this kernel: https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\n\nThis will make sense only if you have a slow CPU (e.g. a free one in online kernels). Ideally, if you have a custom rig, your CPU should be fast enough to process images faster than the GPU can consume them (GPU resources shouldn't be wasted on augmentations).",
          "votes": 1
        }
      ]
    },
    {
      "id": 928514,
      "postDate": "2020-07-14T03:56:28.420Z",
      "content": "<p>Hi All, </p>\n\n<p>I read multiple places where the augmentations can be sped up by making the CPU prepare the next batch while the GPU trains on the data and does all the cool stuff.</p>\n\n<p>However, I couldn't find any documentation/ code about it. If there is something that can be shared here, I'd really appreciate it. Thank you.</p>",
      "rawMarkdown": "Hi All, \n\nI read multiple places where the augmentations can be sped up by making the CPU prepare the next batch while the GPU trains on the data and does all the cool stuff.\n\nHowever, I couldn't find any documentation/ code about it. If there is something that can be shared here, I'd really appreciate it. Thank you."
    }
  ],
  "comments": [
    {
      "id": 1112797,
      "author_name": "Dawood Aijaz",
      "author_url": "",
      "post_date": "2020-12-14T22:36:18.977000",
      "content": "<p>Hi,<br>\ncheck out the following link about data augmentation in TF<br>\n<a href=\"https://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3\" target=\"_blank\">https://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3</a></p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 928686,
      "author_name": "nEO",
      "author_url": "",
      "post_date": "2020-07-14T06:43:20.207000",
      "content": "<p>I think I found my answer. Looking at this notebook\n<a href=\"https://www.kaggle.com/nitindatta/flower-classification-augmentations-eda\">https://www.kaggle.com/nitindatta/flower-classification-augmentations-eda</a></p>\n\n<p>and the following documentation on Tensorflow's website gave me many of the answers I was looking for\n<a href=\"https://www.tensorflow.org/guide/data_performance\">https://www.tensorflow.org/guide/data_performance</a>\n<a href=\"https://www.tensorflow.org/tutorials/images/data_augmentation\">https://www.tensorflow.org/tutorials/images/data_augmentation</a></p>\n\n<p>Hopefully if someone else was looking for these answers finds this post useful.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 952797,
          "author_name": "Chan Kha Vu",
          "author_url": "",
          "post_date": "2020-07-31T08:25:06.317000",
          "content": "<p>Please note that the trick above (in the notebook you cited) actually does augmentation on GPU, not CPU. A more detailed explanation in this kernel: <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96</a></p>\n\n<p>This will make sense only if you have a slow CPU (e.g. a free one in online kernels). Ideally, if you have a custom rig, your CPU should be fast enough to process images faster than the GPU can consume them (GPU resources shouldn't be wasted on augmentations).</p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1112797": "Hi,\ncheck out the following link about data augmentation in TF\nhttps://www.tensorflow.org/tutorials/images/data_augmentation#data_augmentation_3",
    "928686": "I think I found my answer. Looking at this notebook\nhttps://www.kaggle.com/nitindatta/flower-classification-augmentations-eda\n\nand the following documentation on Tensorflow's website gave me many of the answers I was looking for\nhttps://www.tensorflow.org/guide/data_performance\nhttps://www.tensorflow.org/tutorials/images/data_augmentation\n\nHopefully if someone else was looking for these answers finds this post useful.",
    "928514": "Hi All, \n\nI read multiple places where the augmentations can be sped up by making the CPU prepare the next batch while the GPU trains on the data and does all the cool stuff.\n\nHowever, I couldn't find any documentation/ code about it. If there is something that can be shared here, I'd really appreciate it. Thank you."
  }
}