title: Pytorch RuntimeError: [enforce fail at CPUAllocator.cpp:56] posix_memalign(&data, gAlignment, nbytes) == 0. 12 vs 0
body: <p>I'm building a simple content based recommendations system. In order to compute the <em>cosine similarity</em> in a GPU accelerated way, i'm using <code>Pytorch</code>.</p>
  
  <p>At the time of creating the <em>tfidf vocabulary tensor</em> from a <code>csr_matrix</code>, it promts the following <em>RuntimeErrorr</em></p>
  
  <p><code>RuntimeError: [enforce fail at CPUAllocator.cpp:56] posix_memalign(&amp;data, gAlignment, nbytes) == 0. 12 vs 0</code></p>
  
  <p>I'm doing it in this way:</p>
  
  <pre><code>coo = tfidf_matrix.tocoo()
  values = coo.data
  indices = np.vstack( (coo.row, coo.col ))
  i = torch.LongTensor(indices)
  v = torch.FloatTensor(values)
  tfidf_matrix_tensor = torch.sparse.FloatTensor(i, v, torch.Size(coo1.shape)).to_dense() 
  # Prompts the error
  </code></pre>
  
  <p>I tried with a small test (tfidf matrix size = 10,296) dataset and it works. 
  The tfidf matrix size from the real dataset is (27639, 226957)</p>