{
  "id": 125938,
  "title": "Ensembling",
  "url": "/competitions/tensorflow2-question-answering/discussion/125938",
  "author_name": "",
  "post_date": "2020-01-14T16:39:50.807529900Z",
  "votes": 3,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Has anyone tried to ensemble two bert-type models together? When I try it locally, I get OOM errors when loading the second model. Did some google searching but there doesn't seem to be a way to clear out the first model from the GPU after it's been used. Wondering if anyone has figured out a workaround.</p>",
  "messages": [
    {
      "id": "718682",
      "postDate": "01/14/2020 16:39:50",
      "content": "<p>Has anyone tried to ensemble two bert-type models together? When I try it locally, I get OOM errors when loading the second model. Did some google searching but there doesn't seem to be a way to clear out the first model from the GPU after it's been used. Wondering if anyone has figured out a workaround.</p>",
      "rawMarkdown": "Has anyone tried to ensemble two bert-type models together? When I try it locally, I get OOM errors when loading the second model. Did some google searching but there doesn't seem to be a way to clear out the first model from the GPU after it's been used. Wondering if anyone has figured out a workaround.",
      "votes": null
    },
    {
      "id": "719107",
      "postDate": "01/15/2020 06:26:12",
      "content": "<p>I have been doing something related, and if you are using Tensorflow 2.X Keras you can run “tf.keras.backend.clear_session()” to get rid of any previous models. As it turns out this will not immediately remove it from the GPU memory, but if you try to create a new model, the memory taken up my the old model should be properly replaced by that of the new model.</p>",
      "rawMarkdown": "I have been doing something related, and if you are using Tensorflow 2.X Keras you can run “tf.keras.backend.clear_session()” to get rid of any previous models. As it turns out this will not immediately remove it from the GPU memory, but if you try to create a new model, the memory taken up my the old model should be properly replaced by that of the new model.",
      "votes": null
    },
    {
      "id": "719271",
      "postDate": "01/15/2020 10:29:45",
      "content": "<p>I have used this in the past to clear out GPU memory. \n<code>\nfrom numba import cuda\ncuda.select_device(0)\ncuda.close()\n</code></p>",
      "rawMarkdown": "I have used this in the past to clear out GPU memory. \n```\nfrom numba import cuda\ncuda.select_device(0)\ncuda.close()\n```",
      "votes": null
    },
    {
      "id": "719706",
      "postDate": "01/15/2020 18:54:14",
      "content": "<p>Great! Will give that a shot. Thanks.</p>",
      "rawMarkdown": "Great! Will give that a shot. Thanks.",
      "votes": null
    },
    {
      "id": "720075",
      "postDate": "01/16/2020 06:06:25",
      "content": "<p>Thanks!</p>",
      "rawMarkdown": "Thanks!",
      "votes": null
    },
    {
      "id": "720077",
      "postDate": "01/16/2020 06:06:38",
      "content": "<p>Thanks!</p>",
      "rawMarkdown": "Thanks!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 719107,
      "author_name": "ejmejm",
      "author_url": "",
      "post_date": "01/15/2020 06:26:12",
      "content": "<p>I have been doing something related, and if you are using Tensorflow 2.X Keras you can run “tf.keras.backend.clear_session()” to get rid of any previous models. As it turns out this will not immediately remove it from the GPU memory, but if you try to create a new model, the memory taken up my the old model should be properly replaced by that of the new model.</p>",
      "votes": null,
      "replies": [
        {
          "id": 719706,
          "author_name": "alonbochman",
          "author_url": "",
          "post_date": "01/15/2020 18:54:14",
          "content": "<p>Great! Will give that a shot. Thanks.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 720075,
          "author_name": "eggachecat",
          "author_url": "",
          "post_date": "01/16/2020 06:06:25",
          "content": "<p>Thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 719271,
      "author_name": "rashmibanthia",
      "author_url": "",
      "post_date": "01/15/2020 10:29:45",
      "content": "<p>I have used this in the past to clear out GPU memory. \n<code>\nfrom numba import cuda\ncuda.select_device(0)\ncuda.close()\n</code></p>",
      "votes": null,
      "replies": [
        {
          "id": 720077,
          "author_name": "eggachecat",
          "author_url": "",
          "post_date": "01/16/2020 06:06:38",
          "content": "<p>Thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "718682": "Has anyone tried to ensemble two bert-type models together? When I try it locally, I get OOM errors when loading the second model. Did some google searching but there doesn't seem to be a way to clear out the first model from the GPU after it's been used. Wondering if anyone has figured out a workaround.",
    "719107": "I have been doing something related, and if you are using Tensorflow 2.X Keras you can run “tf.keras.backend.clear_session()” to get rid of any previous models. As it turns out this will not immediately remove it from the GPU memory, but if you try to create a new model, the memory taken up my the old model should be properly replaced by that of the new model.",
    "719271": "I have used this in the past to clear out GPU memory. \n```\nfrom numba import cuda\ncuda.select_device(0)\ncuda.close()\n```",
    "719706": "Great! Will give that a shot. Thanks.",
    "720075": "Thanks!",
    "720077": "Thanks!"
  },
  "source": "meta"
}