{
  "id": 121533,
  "title": "Training on TPU inferencing on GPU",
  "url": "/competitions/deepfake-detection-challenge/discussion/121533",
  "author_name": "cihan karadoğan",
  "post_date": "2019-12-13T22:17:06.045000",
  "votes": 0,
  "comment_count": 7,
  "views": 0,
  "content": "<p>How can I do training on TPU and inferencing on GPU by using gcp?</p>",
  "messages": [
    {
      "id": 694690,
      "postDate": "2019-12-14T01:24:12.653Z",
      "content": "<p>You should probably use tensorflow/pytorch that supports tpu training. \nThis is the tensorflow code you need to add:\n`tpuclusterresolver = tf.contrib.clusterresolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpuzone,\nproject=FLAGS.gcp_project)</p>\n\n<p>config = tpuconfig.RunConfig( cluster=tpuclusterresolver, modeldir=FLAGS.modeldir, savecheckpointssteps=max(600, FLAGS.iterationsperloop), tpuconfig=tpuconfig.TPUConfig( iterationsperloop=FLAGS.iterationsperloop, numshards=FLAGS.numcores, perhostinputfortraining=tpuconfig.InputPipelineConfig.PERHOSTV2))`</p>\n\n<p>from <a href=\"https://cloud.google.com/ml-engine/docs/tensorflow/using-tpus\">here</a>\nhope this helps</p>",
      "rawMarkdown": "You should probably use tensorflow/pytorch that supports tpu training. \nThis is the tensorflow code you need to add:\n`tpuclusterresolver = tf.contrib.clusterresolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpuzone,\nproject=FLAGS.gcp_project)\n\nconfig = tpuconfig.RunConfig( cluster=tpuclusterresolver, modeldir=FLAGS.modeldir, savecheckpointssteps=max(600, FLAGS.iterationsperloop), tpuconfig=tpuconfig.TPUConfig( iterationsperloop=FLAGS.iterationsperloop, numshards=FLAGS.numcores, perhostinputfortraining=tpuconfig.InputPipelineConfig.PERHOSTV2))`\n\nfrom [here](https://cloud.google.com/ml-engine/docs/tensorflow/using-tpus)\nhope this helps",
      "votes": 1,
      "replies": [
        {
          "id": 694871,
          "postDate": "2019-12-14T08:33:35.327Z",
          "content": "<p>Thank you for your help, but that's not what I meant. I decided to do the training with TPU because of the large data size, but the code requirements section says that I need to use GPU and CPU. Is there any way I can use TPU for training and use GPU for submission?</p>",
          "rawMarkdown": "Thank you for your help, but that's not what I meant. I decided to do the training with TPU because of the large data size, but the code requirements section says that I need to use GPU and CPU. Is there any way I can use TPU for training and use GPU for submission?"
        },
        {
          "id": 695209,
          "postDate": "2019-12-14T19:05:52.387Z",
          "content": "<p>I believe you could train a model using TPUs, upload the trained model to Kaggle, and then use Kaggle's GPUs to run the trained model.</p>",
          "rawMarkdown": "I believe you could train a model using TPUs, upload the trained model to Kaggle, and then use Kaggle's GPUs to run the trained model.",
          "votes": 1
        },
        {
          "id": 695237,
          "postDate": "2019-12-14T20:25:24.470Z",
          "content": "<p>Sorry for misunderstanding your question. You will need to transform it from tpu model to gpu model. according to <a href=\"https://cloud.google.com/blog/products/ai-machine-learning/train-fast-on-tpu-serve-flexibly-on-gpu-switch-your-ml-infrastructure-to-suit-your-needs\">click me</a> \nhope this helps. </p>",
          "rawMarkdown": "Sorry for misunderstanding your question. You will need to transform it from tpu model to gpu model. according to [click me](https://cloud.google.com/blog/products/ai-machine-learning/train-fast-on-tpu-serve-flexibly-on-gpu-switch-your-ml-infrastructure-to-suit-your-needs) \nhope this helps. "
        },
        {
          "id": 695259,
          "postDate": "2019-12-14T21:21:18.303Z",
          "content": "<p>Thanks for your help.</p>",
          "rawMarkdown": "Thanks for your help."
        },
        {
          "id": 695262,
          "postDate": "2019-12-14T21:32:50.507Z",
          "content": "<p>Anytime.</p>",
          "rawMarkdown": "Anytime.",
          "votes": 1
        }
      ]
    },
    {
      "id": 694648,
      "postDate": "2019-12-13T22:17:06.047Z",
      "content": "<p>How can I do training on TPU and inferencing on GPU by using gcp?</p>",
      "rawMarkdown": "How can I do training on TPU and inferencing on GPU by using gcp?"
    },
    {
      "id": 694870,
      "postDate": "2019-12-14T08:32:58.710Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 694690,
      "author_name": "Shangqiu Li",
      "author_url": "",
      "post_date": "2019-12-14T01:24:12.653000",
      "content": "<p>You should probably use tensorflow/pytorch that supports tpu training. \nThis is the tensorflow code you need to add:\n`tpuclusterresolver = tf.contrib.clusterresolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpuzone,\nproject=FLAGS.gcp_project)</p>\n\n<p>config = tpuconfig.RunConfig( cluster=tpuclusterresolver, modeldir=FLAGS.modeldir, savecheckpointssteps=max(600, FLAGS.iterationsperloop), tpuconfig=tpuconfig.TPUConfig( iterationsperloop=FLAGS.iterationsperloop, numshards=FLAGS.numcores, perhostinputfortraining=tpuconfig.InputPipelineConfig.PERHOSTV2))`</p>\n\n<p>from <a href=\"https://cloud.google.com/ml-engine/docs/tensorflow/using-tpus\">here</a>\nhope this helps</p>",
      "votes": 1,
      "replies": [
        {
          "id": 694871,
          "author_name": "cihan karadoğan",
          "author_url": "",
          "post_date": "2019-12-14T08:33:35.327000",
          "content": "<p>Thank you for your help, but that's not what I meant. I decided to do the training with TPU because of the large data size, but the code requirements section says that I need to use GPU and CPU. Is there any way I can use TPU for training and use GPU for submission?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 695209,
          "author_name": "Carlos Souza",
          "author_url": "",
          "post_date": "2019-12-14T19:05:52.387000",
          "content": "<p>I believe you could train a model using TPUs, upload the trained model to Kaggle, and then use Kaggle's GPUs to run the trained model.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 695237,
          "author_name": "Shangqiu Li",
          "author_url": "",
          "post_date": "2019-12-14T20:25:24.470000",
          "content": "<p>Sorry for misunderstanding your question. You will need to transform it from tpu model to gpu model. according to <a href=\"https://cloud.google.com/blog/products/ai-machine-learning/train-fast-on-tpu-serve-flexibly-on-gpu-switch-your-ml-infrastructure-to-suit-your-needs\">click me</a> \nhope this helps. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 695259,
          "author_name": "cihan karadoğan",
          "author_url": "",
          "post_date": "2019-12-14T21:21:18.303000",
          "content": "<p>Thanks for your help.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 695262,
          "author_name": "Shangqiu Li",
          "author_url": "",
          "post_date": "2019-12-14T21:32:50.507000",
          "content": "<p>Anytime.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 694870,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-12-14T08:32:58.710000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "694690": "You should probably use tensorflow/pytorch that supports tpu training. \nThis is the tensorflow code you need to add:\n`tpuclusterresolver = tf.contrib.clusterresolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpuzone,\nproject=FLAGS.gcp_project)\n\nconfig = tpuconfig.RunConfig( cluster=tpuclusterresolver, modeldir=FLAGS.modeldir, savecheckpointssteps=max(600, FLAGS.iterationsperloop), tpuconfig=tpuconfig.TPUConfig( iterationsperloop=FLAGS.iterationsperloop, numshards=FLAGS.numcores, perhostinputfortraining=tpuconfig.InputPipelineConfig.PERHOSTV2))`\n\nfrom [here](https://cloud.google.com/ml-engine/docs/tensorflow/using-tpus)\nhope this helps",
    "694648": "How can I do training on TPU and inferencing on GPU by using gcp?",
    "694870": ""
  }
}