{
  "id": 233399,
  "title": "How to optimize cpu and ram usage?",
  "url": "/competitions/indoor-location-navigation/discussion/233399",
  "author_name": "",
  "post_date": "2021-04-19T02:29:17.112962300Z",
  "votes": 1,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I am trying to use GPU using this command</p>\n<p><code>'cuda' if torch.cuda.is_available() else 'cpu'</code></p>\n<p>But the CPU consumption percentage increases to 199% and RAM usage jumps rapidly to 13GB. While neither GPU memory is not used nor GPU processing is used as per draft session. </p>\n<p>Note: I'm new to Kaggle </p>",
  "messages": [
    {
      "id": "1277630",
      "postDate": "04/19/2021 02:29:17",
      "content": "<p>I am trying to use GPU using this command</p>\n<p><code>'cuda' if torch.cuda.is_available() else 'cpu'</code></p>\n<p>But the CPU consumption percentage increases to 199% and RAM usage jumps rapidly to 13GB. While neither GPU memory is not used nor GPU processing is used as per draft session. </p>\n<p>Note: I'm new to Kaggle </p>",
      "rawMarkdown": "I am trying to use GPU using this command\n\n`'cuda' if torch.cuda.is_available() else 'cpu'`\n\nBut the CPU consumption percentage increases to 199% and RAM usage jumps rapidly to 13GB. While neither GPU memory is not used nor GPU processing is used as per draft session. \n\nNote: I'm new to Kaggle",
      "votes": null
    },
    {
      "id": "1277641",
      "postDate": "04/19/2021 03:07:10",
      "content": "<p>Here's a snippet from how I use it (cuda:0), with a print statement - what does this print out?</p>\n<p>device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")<br>\nprint(device)</p>",
      "rawMarkdown": "Here's a snippet from how I use it (cuda:0), with a print statement - what does this print out?\n\ndevice = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\nprint(device)",
      "votes": null
    },
    {
      "id": "1277649",
      "postDate": "04/19/2021 03:22:28",
      "content": "<p>Result for <br>\n<code>device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")</code><br>\n<code>print(device)</code></p>\n<p><code>cuda:0</code></p>\n<p>Screenshot can be found here:<br>\n<a href=\"url\" target=\"_blank\">https://www.dropbox.com/s/y2fkjy2erl3qb8p/kaggel_gpu_issue.png?dl=0</a></p>",
      "rawMarkdown": "Result for \n`device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")`\n`print(device)`\n\n`cuda:0`\n\nScreenshot can be found here:\n[https://www.dropbox.com/s/y2fkjy2erl3qb8p/kaggel_gpu_issue.png?dl=0](url)",
      "votes": null
    },
    {
      "id": "1277670",
      "postDate": "04/19/2021 04:05:18",
      "content": "<p>Ok, that shows it's available, so that's good - are you then sending both your model and data to that device with \".to(device)\"?  That will look something like this:</p>\n<p>model = MyModel()<br>\nmodel.to(device)</p>\n<p>X_train = torch.FloatTensor(X_train).to(device)<br>\nY_train = torch.FloatTensor(Y_train).to(device)</p>",
      "rawMarkdown": "Ok, that shows it's available, so that's good - are you then sending both your model and data to that device with \".to(device)\"?  That will look something like this:\n\nmodel = MyModel()\nmodel.to(device)\n\nX_train = torch.FloatTensor(X_train).to(device)\nY_train = torch.FloatTensor(Y_train).to(device)",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1277641,
      "author_name": "chris62",
      "author_url": "",
      "post_date": "04/19/2021 03:07:10",
      "content": "<p>Here's a snippet from how I use it (cuda:0), with a print statement - what does this print out?</p>\n<p>device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")<br>\nprint(device)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1277649,
      "author_name": "muhammad2421",
      "author_url": "",
      "post_date": "04/19/2021 03:22:28",
      "content": "<p>Result for <br>\n<code>device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")</code><br>\n<code>print(device)</code></p>\n<p><code>cuda:0</code></p>\n<p>Screenshot can be found here:<br>\n<a href=\"url\" target=\"_blank\">https://www.dropbox.com/s/y2fkjy2erl3qb8p/kaggel_gpu_issue.png?dl=0</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 1277670,
          "author_name": "chris62",
          "author_url": "",
          "post_date": "04/19/2021 04:05:18",
          "content": "<p>Ok, that shows it's available, so that's good - are you then sending both your model and data to that device with \".to(device)\"?  That will look something like this:</p>\n<p>model = MyModel()<br>\nmodel.to(device)</p>\n<p>X_train = torch.FloatTensor(X_train).to(device)<br>\nY_train = torch.FloatTensor(Y_train).to(device)</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1277630": "I am trying to use GPU using this command\n\n`'cuda' if torch.cuda.is_available() else 'cpu'`\n\nBut the CPU consumption percentage increases to 199% and RAM usage jumps rapidly to 13GB. While neither GPU memory is not used nor GPU processing is used as per draft session. \n\nNote: I'm new to Kaggle",
    "1277641": "Here's a snippet from how I use it (cuda:0), with a print statement - what does this print out?\n\ndevice = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\nprint(device)",
    "1277649": "Result for \n`device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")`\n`print(device)`\n\n`cuda:0`\n\nScreenshot can be found here:\n[https://www.dropbox.com/s/y2fkjy2erl3qb8p/kaggel_gpu_issue.png?dl=0](url)",
    "1277670": "Ok, that shows it's available, so that's good - are you then sending both your model and data to that device with \".to(device)\"?  That will look something like this:\n\nmodel = MyModel()\nmodel.to(device)\n\nX_train = torch.FloatTensor(X_train).to(device)\nY_train = torch.FloatTensor(Y_train).to(device)"
  },
  "source": "meta"
}