title: How to calculate pairwise distance matrix on the GPU
body: <p>The bottleneck in my code is the area where I calculate a <a href="https://en.wikipedia.org/wiki/Distance_matrix" rel="noreferrer">pairwise distance matrix</a>.  Since this is the slowest part by far, I have spent much time in speeding up my code.  </p>
  
  <p>I have found many speedups using articles online, but the gains have been minimal.  So, <strong>I am looking for a method to use my GPU to create a distance matrix</strong> in order to speed it up further.  However, I know very little about using the GPU for computation.  <strong>Can anyone help me do this?</strong></p>
  
  <p>In my research I have found the following, but <strong>none of them used the GPU</strong>:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/28693494/python-pairwise-distance-need-a-fast-way-to-do-it">This article</a> was useful, but the speedups were minimal.</li>
  <li><a href="http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/" rel="noreferrer">This article</a> was informative on how to use cython and numba.  </li>
  </ol>
  
  <p>Here is an example snippet of how to calculate a pairwise distance matrix:</p>
  
  <pre><code>import numpy as np
  from scipy import spatial
  
  rows = 1000
  cols = 10
  mat = np.random.randn(rows, cols)
  d_mat = spatial.distance.cdist(mat, mat)
  </code></pre>
  
  <p>My graphics card is an Nvidia Quadro M2000M</p>