{
  "id": 55277,
  "title": "Is there a function which returns memory in use?",
  "url": "/competitions/talkingdata-adtracking-fraud-detection/discussion/55277",
  "author_name": "",
  "post_date": "2018-04-24T16:41:30.383695500Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Whenever I try to run a Kernel for this competition, I get a 137 error code which means that I've exceeded the available memory. I would love to know which parts of my code are using up the most memory. I did a google search but couldn't find any function which would return how much memory is used up. </p>\n\n<p>Could someone help me with the method they use to check which variables/parts of code are using up the most memory?</p>",
  "messages": [
    {
      "id": "318874",
      "postDate": "04/24/2018 16:41:30",
      "content": "<p>Whenever I try to run a Kernel for this competition, I get a 137 error code which means that I've exceeded the available memory. I would love to know which parts of my code are using up the most memory. I did a google search but couldn't find any function which would return how much memory is used up. </p>\n\n<p>Could someone help me with the method they use to check which variables/parts of code are using up the most memory?</p>",
      "rawMarkdown": "Whenever I try to run a Kernel for this competition, I get a 137 error code which means that I've exceeded the available memory. I would love to know which parts of my code are using up the most memory. I did a google search but couldn't find any function which would return how much memory is used up. \n\nCould someone help me with the method they use to check which variables/parts of code are using up the most memory?",
      "votes": null
    },
    {
      "id": "318883",
      "postDate": "04/24/2018 16:55:53",
      "content": "<p>try this by @ RDizzl3:</p>\n\n<pre><code>def cpuStats():\n    print(sys.version)\n    print(psutil.cpu_percent())\n    print(psutil.virtual_memory())  # physical memory usage\n    pid = os.getpid()\n    py = psutil.Process(pid)\n    memoryUse = py.memory_info()[0] / 2. ** 30\n    print('memory GB:', memoryUse)\n</code></pre>\n\n<p><a href=\"https://www.kaggle.com/c/mercari-price-suggestion-challenge/discussion/45558#259097\">source</a></p>",
      "rawMarkdown": "try this by @ RDizzl3:\n\n    def cpuStats():\n        print(sys.version)\n        print(psutil.cpu_percent())\n        print(psutil.virtual_memory())  # physical memory usage\n        pid = os.getpid()\n        py = psutil.Process(pid)\n        memoryUse = py.memory_info()[0] / 2. ** 30\n        print('memory GB:', memoryUse)\n\n[source][1]\n\n\n  [1]: https://www.kaggle.com/c/mercari-price-suggestion-challenge/discussion/45558#259097",
      "votes": null
    },
    {
      "id": "318888",
      "postDate": "04/24/2018 17:25:04",
      "content": "<p>Works like a charm. Thanks!</p>",
      "rawMarkdown": "Works like a charm. Thanks!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 318883,
      "author_name": "sohaibomar",
      "author_url": "",
      "post_date": "04/24/2018 16:55:53",
      "content": "<p>try this by @ RDizzl3:</p>\n\n<pre><code>def cpuStats():\n    print(sys.version)\n    print(psutil.cpu_percent())\n    print(psutil.virtual_memory())  # physical memory usage\n    pid = os.getpid()\n    py = psutil.Process(pid)\n    memoryUse = py.memory_info()[0] / 2. ** 30\n    print('memory GB:', memoryUse)\n</code></pre>\n\n<p><a href=\"https://www.kaggle.com/c/mercari-price-suggestion-challenge/discussion/45558#259097\">source</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 318888,
          "author_name": "sudeepshukla",
          "author_url": "",
          "post_date": "04/24/2018 17:25:04",
          "content": "<p>Works like a charm. Thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "318874": "Whenever I try to run a Kernel for this competition, I get a 137 error code which means that I've exceeded the available memory. I would love to know which parts of my code are using up the most memory. I did a google search but couldn't find any function which would return how much memory is used up. \n\nCould someone help me with the method they use to check which variables/parts of code are using up the most memory?",
    "318883": "try this by @ RDizzl3:\n\n    def cpuStats():\n        print(sys.version)\n        print(psutil.cpu_percent())\n        print(psutil.virtual_memory())  # physical memory usage\n        pid = os.getpid()\n        py = psutil.Process(pid)\n        memoryUse = py.memory_info()[0] / 2. ** 30\n        print('memory GB:', memoryUse)\n\n[source][1]\n\n\n  [1]: https://www.kaggle.com/c/mercari-price-suggestion-challenge/discussion/45558#259097",
    "318888": "Works like a charm. Thanks!"
  },
  "source": "meta"
}