{
  "id": 199415,
  "title": "Deleting objects from GPU memory",
  "url": "/competitions/riiid-test-answer-prediction/discussion/199415",
  "author_name": "",
  "post_date": "2020-11-25T16:46:19.981264500Z",
  "votes": 3,
  "comment_count": 3,
  "views": 0,
  "content": "<p>When I try to do something like</p>\n<p><code>del train</code><br>\n<code>gc.collect()</code></p>\n<p>I notice that in the bar in the top right of the kernal, the amount of memory used by the GPU is unchanged. </p>\n<p>Can anybody explain why this is not freeing up space? Could you recommend an alternative method to free up GPU space? </p>",
  "messages": [
    {
      "id": "1090894",
      "postDate": "11/25/2020 16:46:19",
      "content": "<p>When I try to do something like</p>\n<p><code>del train</code><br>\n<code>gc.collect()</code></p>\n<p>I notice that in the bar in the top right of the kernal, the amount of memory used by the GPU is unchanged. </p>\n<p>Can anybody explain why this is not freeing up space? Could you recommend an alternative method to free up GPU space? </p>",
      "rawMarkdown": "When I try to do something like\n\n`del train`\n`gc.collect()`\n\nI notice that in the bar in the top right of the kernal, the amount of memory used by the GPU is unchanged. \n\nCan anybody explain why this is not freeing up space? Could you recommend an alternative method to free up GPU space?",
      "votes": null
    },
    {
      "id": "1120572",
      "postDate": "12/20/2020 23:24:27",
      "content": "<p>Did you find a solution to this? Having the same problem.</p>",
      "rawMarkdown": "Did you find a solution to this? Having the same problem.",
      "votes": null
    },
    {
      "id": "1187798",
      "postDate": "02/05/2021 18:13:06",
      "content": "<p>I know I'm late to the party here, but have you tried something like tf.keras.backend.clear_session()?</p>",
      "rawMarkdown": "I know I'm late to the party here, but have you tried something like tf.keras.backend.clear_session()?",
      "votes": null
    },
    {
      "id": "1187968",
      "postDate": "02/05/2021 20:13:36",
      "content": "<p>Even if you free up memory, it only marks those blocks as available for re-writing, but the actual release from system memory happens later, even if you do <code>gc.collect</code>. However, you asked about GPU memory, not CPU memory, which I think has a different process.</p>",
      "rawMarkdown": "Even if you free up memory, it only marks those blocks as available for re-writing, but the actual release from system memory happens later, even if you do `gc.collect`. However, you asked about GPU memory, not CPU memory, which I think has a different process.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1120572,
      "author_name": "tskelton12",
      "author_url": "",
      "post_date": "12/20/2020 23:24:27",
      "content": "<p>Did you find a solution to this? Having the same problem.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1187798,
      "author_name": "ottpocket",
      "author_url": "",
      "post_date": "02/05/2021 18:13:06",
      "content": "<p>I know I'm late to the party here, but have you tried something like tf.keras.backend.clear_session()?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1187968,
      "author_name": "philipkd",
      "author_url": "",
      "post_date": "02/05/2021 20:13:36",
      "content": "<p>Even if you free up memory, it only marks those blocks as available for re-writing, but the actual release from system memory happens later, even if you do <code>gc.collect</code>. However, you asked about GPU memory, not CPU memory, which I think has a different process.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1090894": "When I try to do something like\n\n`del train`\n`gc.collect()`\n\nI notice that in the bar in the top right of the kernal, the amount of memory used by the GPU is unchanged. \n\nCan anybody explain why this is not freeing up space? Could you recommend an alternative method to free up GPU space?",
    "1120572": "Did you find a solution to this? Having the same problem.",
    "1187798": "I know I'm late to the party here, but have you tried something like tf.keras.backend.clear_session()?",
    "1187968": "Even if you free up memory, it only marks those blocks as available for re-writing, but the actual release from system memory happens later, even if you do `gc.collect`. However, you asked about GPU memory, not CPU memory, which I think has a different process."
  },
  "source": "meta"
}