{
  "id": 10086,
  "title": "Memory error executing vanilla avito_ProhibitedContent_SampleCode.py",
  "url": "/competitions/avito-prohibited-content/discussion/10086",
  "author_name": "",
  "post_date": "2014-08-20T16:48:20.497Z",
  "votes": null,
  "comment_count": 2,
  "views": 3611,
  "content": "<p>Hi,</p>\n<p>After reading avito_ProhibitedContent_SampleCode I understood that I needed a &quot;train_data.pkl&quot;.</p>\n<p>I noticed that the main procedure have four commented lines, followed by one uncommented line.</p>\n<p>I thought that these uncommented lines are the way to get &quot;train_data.pkl&quot; in the first execution. So the .tsv file can be processed, serialized and stored into &quot;train_data.pkl&quot;</p>\n<p>In order to get that, I inverted the comments, and executed the following main procedure:</p>\n<p style=\"padding-left: 30px\">featureIndexes = processData(os.path.join(dataFolder,&quot;avito_train.tsv&quot;), itemsLimit=300000)<br> trainFeatures,trainTargets, trainItemIds=processData(os.path.join(dataFolder,&quot;avito_train.tsv&quot;), featureIndexes, itemsLimit=300000)<br> testFeatures, testItemIds=processData(os.path.join(dataFolder,&quot;avito_test.tsv&quot;), featureIndexes)<br> joblib.dump((trainFeatures, trainTargets, trainItemIds, testFeatures, testItemIds), os.path.join(dataFolder,&quot;train_data.pkl&quot;))<br><strong>#</strong> trainFeatures, trainTargets, trainItemIds, testFeatures, testItemIds = joblib.load(os.path.join(dataFolder,&quot;train_data.pkl&quot;))</p>\n<p>But after the execution I got a memory error:</p>\n<p style=\"padding-left: 30px\">[LINE:109]# DEBUG [2014-08-20 17:54:17,323] Generate features for avito_test<br>.tsv: 1350000 items done<br>[LINE:109]# DEBUG [2014-08-20 17:54:17,611] Generate features for avito_test<br>.tsv: 1351000 items done<br>Traceback (most recent call last):<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 158, in &lt;module&gt;<br> main()<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 131, in main<br> testFeatures, testItemIds=processData(os.path.join(dataFolder,&quot;avito_test.ts<br>v&quot;), featureIndexes)<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 120, in processData<br> features = sp.csr_matrix((np.ones(len(row)),(row,col)), shape=(cur_row, len(<br>featureIndexes)), dtype=np.float64)<br> File &quot;W:\\Python27\\lib\\site-packages\\scipy\\sparse\\compressed.py&quot;, line 48, in _<br>_init__<br> other = self.__class__(coo_matrix(arg1, shape=shape))<br> File &quot;W:\\Python27\\lib\\site-packages\\scipy\\sparse\\coo.py&quot;, line 139, in __init_<br>_<br> self.row = np.array(ij[0], copy=copy)<br>MemoryError</p>\n<p><br>My laptop is a 32 bit Windows Vista with 4GB (but using only 3GB as Vista does). I started executing it with 2GB free memory, and it seems like it has crashed with 1GB free memory (according to task manager graph but not very sure)</p>\n<p>What have I done wrong?</p>\n<p>Thanks in advance</p>",
  "messages": [
    {
      "id": "52241",
      "postDate": "08/20/2014 16:48:20",
      "content": "<p>Hi,</p>\n<p>After reading avito_ProhibitedContent_SampleCode I understood that I needed a &quot;train_data.pkl&quot;.</p>\n<p>I noticed that the main procedure have four commented lines, followed by one uncommented line.</p>\n<p>I thought that these uncommented lines are the way to get &quot;train_data.pkl&quot; in the first execution. So the .tsv file can be processed, serialized and stored into &quot;train_data.pkl&quot;</p>\n<p>In order to get that, I inverted the comments, and executed the following main procedure:</p>\n<p style=\"padding-left: 30px\">featureIndexes = processData(os.path.join(dataFolder,&quot;avito_train.tsv&quot;), itemsLimit=300000)<br> trainFeatures,trainTargets, trainItemIds=processData(os.path.join(dataFolder,&quot;avito_train.tsv&quot;), featureIndexes, itemsLimit=300000)<br> testFeatures, testItemIds=processData(os.path.join(dataFolder,&quot;avito_test.tsv&quot;), featureIndexes)<br> joblib.dump((trainFeatures, trainTargets, trainItemIds, testFeatures, testItemIds), os.path.join(dataFolder,&quot;train_data.pkl&quot;))<br><strong>#</strong> trainFeatures, trainTargets, trainItemIds, testFeatures, testItemIds = joblib.load(os.path.join(dataFolder,&quot;train_data.pkl&quot;))</p>\n<p>But after the execution I got a memory error:</p>\n<p style=\"padding-left: 30px\">[LINE:109]# DEBUG [2014-08-20 17:54:17,323] Generate features for avito_test<br>.tsv: 1350000 items done<br>[LINE:109]# DEBUG [2014-08-20 17:54:17,611] Generate features for avito_test<br>.tsv: 1351000 items done<br>Traceback (most recent call last):<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 158, in &lt;module&gt;<br> main()<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 131, in main<br> testFeatures, testItemIds=processData(os.path.join(dataFolder,&quot;avito_test.ts<br>v&quot;), featureIndexes)<br> File &quot;avito_ProhibitedContent_SampleCode.py&quot;, line 120, in processData<br> features = sp.csr_matrix((np.ones(len(row)),(row,col)), shape=(cur_row, len(<br>featureIndexes)), dtype=np.float64)<br> File &quot;W:\\Python27\\lib\\site-packages\\scipy\\sparse\\compressed.py&quot;, line 48, in _<br>_init__<br> other = self.__class__(coo_matrix(arg1, shape=shape))<br> File &quot;W:\\Python27\\lib\\site-packages\\scipy\\sparse\\coo.py&quot;, line 139, in __init_<br>_<br> self.row = np.array(ij[0], copy=copy)<br>MemoryError</p>\n<p><br>My laptop is a 32 bit Windows Vista with 4GB (but using only 3GB as Vista does). I started executing it with 2GB free memory, and it seems like it has crashed with 1GB free memory (according to task manager graph but not very sure)</p>\n<p>What have I done wrong?</p>\n<p>Thanks in advance</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "52288",
      "postDate": "08/21/2014 13:35:01",
      "content": "<p>I've noticed in the past windows having a limit of ~ 1GB ram per process.</p>\n<p>It might sound strange, but running a unix virtual machine instead may work for you.</p>\n<p>On a Win 7 host with a Virtual Box guest the benchmark runs fine for me.</p>\n<p>But I am on 64 bit.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "53684",
      "postDate": "09/14/2014 10:09:02",
      "content": "<p>Problem solved using a different operating system</p>\n\n<p>Thanks a lot!</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 52288,
      "author_name": "devcon",
      "author_url": "",
      "post_date": "08/21/2014 13:35:01",
      "content": "<p>I've noticed in the past windows having a limit of ~ 1GB ram per process.</p>\n<p>It might sound strange, but running a unix virtual machine instead may work for you.</p>\n<p>On a Win 7 host with a Virtual Box guest the benchmark runs fine for me.</p>\n<p>But I am on 64 bit.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 53684,
      "author_name": "virilo",
      "author_url": "",
      "post_date": "09/14/2014 10:09:02",
      "content": "<p>Problem solved using a different operating system</p>\n\n<p>Thanks a lot!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "52241": "",
    "52288": "",
    "53684": ""
  },
  "source": "meta"
}