<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[gpu - Matthias Lee - Musings on Software and Performance Engineering]]></title><description><![CDATA[Matthias Lee is a Software Performance Engineer, Technical Lead and Computer Science PhD. Currently a Principal Performance Engineer at Appian.]]></description><link>https://matthiaslee.com/</link><image><url>https://matthiaslee.com/favicon.png</url><title>gpu - Matthias Lee - Musings on Software and Performance Engineering</title><link>https://matthiaslee.com/</link></image><generator>Ghost 2.14</generator><lastBuildDate>Tue, 23 Dec 2025 06:00:07 GMT</lastBuildDate><atom:link href="https://matthiaslee.com/tag/gpu/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Using pyGASP; Python Signal Processing(FFT,DWT,DCT) library with GPU-acceleration via pyCUDA]]></title><description><![CDATA[<p>I came across pyGASP while I was working on my Image Deconvolution research. It seems to be one of the only python tools which provides &quot;GPU-accellerated&quot; Discrete Wavelet Transforms. It features a barebones API similar to pywt. Sadly the docs and &quot;performance&quot; are a bit lacking,</p>]]></description><link>https://matthiaslee.com/using-pygasp-python-fast-fourier-wavelet-and-cosine-transform-library-with-a-gpu-acceleration-via-pycuda/</link><guid isPermaLink="false">5a0a60d882e47c00018dabdd</guid><category><![CDATA[pygasp]]></category><category><![CDATA[pycuda]]></category><category><![CDATA[gpu]]></category><category><![CDATA[python]]></category><category><![CDATA[dwt]]></category><category><![CDATA[wavelet]]></category><dc:creator><![CDATA[Matthias A. Lee]]></dc:creator><pubDate>Wed, 15 Jan 2014 16:27:51 GMT</pubDate><content:encoded><![CDATA[<p>I came across pyGASP while I was working on my Image Deconvolution research. It seems to be one of the only python tools which provides &quot;GPU-accellerated&quot; Discrete Wavelet Transforms. It features a barebones API similar to pywt. Sadly the docs and &quot;performance&quot; are a bit lacking, so here are some of my notes on getting it working and benchmarking it a bit.. <em><strong>Turns out that the pyGASP GPU code is about 5x slower than the CPU-based pywt (At least in my test case)</strong></em></p>
<h3 id="gettingstarted">Getting Started...</h3>
<h4 id="installingpygasp">Installing pyGASP:</h4>
<p>Easiest way to install pyGASP is using pip or a similar tool.</p>
<pre><code>$&gt; sudo pip install pygasp
</code></pre>
<h4 id="documentation">Documentation:</h4>
<p>The official documentation can be found here: <a href="http://pythonhosted.org/PyGASP/">http://pythonhosted.org/PyGASP/</a><br>
and here: <a href="https://pypi.python.org/pypi/PyGASP">https://pypi.python.org/pypi/PyGASP</a></p>
<p>The docstring generated documentation is not too bad and certainly gives you the basics. The README on the other hand is a out of date. Following are my notes on evaluating it.</p>
<h3 id="pywtvspygaspbenchmarkingthe2dwavelettransform">pywt vs pyGASP; Benchmarking the 2D wavelet transform:</h3>
<p>I am only going to compare dwt2 between these two packages. I, perhaps wrongly, assume other comparisons would yield similar results.</p>
<pre><code>import numpy as np
import scipy.misc
import pylab
from datetime import datetime as dt

import pywt
import pygasp.dwt.dwt as pygaspDWT
import pygasp.dwt.dwtCuda as pygaspDWTgpu

def show(data):
    pylab.jet()
    pylab.imshow(data)
    pylab.colorbar()
    pylab.show()
	pylab.clf()

# Lets get an image to play with.
img = scipy.misc.lena().astype(np.float32)

# pywt
s = dt.now()
res_pywt = pywt.dwt2(img, &quot;haar&quot;, &quot;zpd&quot;)
print &quot;pywt took:&quot;, dt.now()-s

# pygasp CPU version
s = dt.now()
res_gasp = pygaspDWT.dwt2(img, &quot;haar&quot;, &quot;zpd&quot;)
print &quot;pygaspCPU took:&quot;, dt.now()-s

# pygasp GPU version
s = dt.now()
res_gaspGPU = pygaspDWTgpu.dwt2(img, &quot;haar&quot;, &quot;zpd&quot;)
print &quot;pygaspGPU took:&quot;, dt.now()-s

# if you want to view the results
#show(res_pywt[0])
#show(res_gasp[0])
#show(res_gaspGPU[0])
</code></pre>
<p>Now that we have a basic comparison, lets grab a larger image and try it again:</p>
<pre><code>$&gt; wget http://i.imgur.com/CjJL2wG.jpg -O largeTest.jpg
</code></pre>
<p>And add the following:</p>
<pre><code># add this at the top
from PIL import Image
.
.
.
# replace the lena image with this:
imgObj = Image.open(&quot;largeTest.jpg&quot;)
img = np.array(imgObj)
</code></pre>
<p>Sadly the results with the larger image are quite disappointing. I had hoped that the pyGASP GPU code would be at least as fast as the CPU-based pywt.</p>
<pre><code>$&gt; python pygaspTest.py
pywt took: 0:00:01.412802
pygaspCPU took: 0:01:34.589889
pygaspGPU took: 0:00:06.963826
</code></pre>
<p>Even though the pyGASP GPU version is 13.5 times faster than its own CPU equivalent, the pywt CPU version is another ~5 times faster!! Perhaps it is not yet prime time for this library, but it might be a starting point to get a truely GPU accelerated version going. These tests were performed on a Nvidia Tesla K20c. For now I will have to venture on to find another faster solution, but I might come back to this and work on optimizing the it to suit my needs. Sadly there is no public code repo available.</p>
<p>Edit: Looks like pyGASP is related to <a href="http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6632683">this paper</a></p>
]]></content:encoded></item></channel></rss>