<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Scipyed Piper</title>
	<atom:link href="http://scipyed.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://scipyed.wordpress.com</link>
	<description>Using scientific programming tools for great victory!</description>
	<lastBuildDate>Tue, 23 Feb 2010 16:46:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='scipyed.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Scipyed Piper</title>
		<link>http://scipyed.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://scipyed.wordpress.com/osd.xml" title="Scipyed Piper" />
	<atom:link rel='hub' href='http://scipyed.wordpress.com/?pushpress=hub'/>
		<item>
		<title>We Have Moved!</title>
		<link>http://scipyed.wordpress.com/2010/02/23/we-have-moved/</link>
		<comments>http://scipyed.wordpress.com/2010/02/23/we-have-moved/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 16:46:27 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=47</guid>
		<description><![CDATA[Find everything from here and more here.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=47&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Find everything from here and more <a title="My Craneium" href="http://craneium.net" target="_blank">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=47&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2010/02/23/we-have-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>IPython in Jaunty</title>
		<link>http://scipyed.wordpress.com/2009/06/06/ipython-jaunty/</link>
		<comments>http://scipyed.wordpress.com/2009/06/06/ipython-jaunty/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 19:08:09 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=30</guid>
		<description><![CDATA[Sweet news.  The bits necessary for ipython&#8217;s parallel computing environment are automatically built into the apt dependencies! This means that installing everything that you need under Jaunty takes simply the following: $sudo apt-get install ipython Viola!  Now for some examples!  (Next post to come!)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=30&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sweet news.  The bits necessary for ipython&#8217;s parallel computing environment are automatically built into the apt dependencies!</p>
<p>This means that installing everything that you need under Jaunty takes simply the following:</p>
<p>$sudo apt-get install ipython</p>
<p>Viola!  Now for some examples!  (Next post to come!)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=30&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/06/06/ipython-jaunty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>Xubuntu Intrepid/Jaunty on the Dell Mini 9</title>
		<link>http://scipyed.wordpress.com/2009/06/06/xubuntu-intrepidjaunty-on-the-dell-mini-9/</link>
		<comments>http://scipyed.wordpress.com/2009/06/06/xubuntu-intrepidjaunty-on-the-dell-mini-9/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 18:55:52 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=26</guid>
		<description><![CDATA[Xubuntu is a wonderful distro for the Dell Mini-9. There are some bumps in getting everything working, but it seems like the worst are targets for fixed in Jaunty. First up. The sound didn&#8217;t work with the default install. The fix for this is really easy I found it here Basically open up &#8216;/etc/modprobe.d/alsa-base&#8217; and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=26&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Xubuntu is a wonderful distro for the Dell Mini-9.  There are some bumps in getting everything working, but it seems like the worst are targets for fixed in Jaunty.</p>
<p>First up.  The sound didn&#8217;t work with the default install.<br />
The fix for this is really easy I found it here</p>
<p>Basically open up &#8216;/etc/modprobe.d/alsa-base&#8217; and add the line:</p>
<p>options snd-hda-intel model=dell</p>
<p>To the end of the file.  Sound worked wonderfully upon reboot.  (fixed in Jaunty)</p>
<p>Next up PEAP with GTC is not supported in the build of network-manager.  To further complicate things the Broadcom driver freezes up if you try to use this mode at all!  For those of us on school/corporate network&#8217;s this simply is unacceptable.  There is a fix using the &#8216;ndiswrapper&#8217; style driver.  I don&#8217;t like this fix, but it works perfectly if you follow the instructions found here:</p>
<p><a title="Ubuntu on the Mini 9" href="http://www.ubuntumini.com/">http://www.ubuntumini.com/</a></p>
<p>(Fixed in Jaunty!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=26&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/06/06/xubuntu-intrepidjaunty-on-the-dell-mini-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>CUDA Textbook</title>
		<link>http://scipyed.wordpress.com/2009/05/29/cuda-textbook/</link>
		<comments>http://scipyed.wordpress.com/2009/05/29/cuda-textbook/#comments</comments>
		<pubDate>Fri, 29 May 2009 16:55:59 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=28</guid>
		<description><![CDATA[The CUDA textbook chapters found here could have saved me a lot of learning pain.  They are really pretty exceptional compared to everything else I have found.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=28&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The CUDA textbook chapters found <a title="CUDA Book Draft" href="http://sites.google.com/site/cudaiap2009/materials-1/cuda-textbook" target="_blank">here</a> could have saved me a lot of learning pain.  They are really pretty exceptional compared to everything else I have found.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=28&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/05/29/cuda-textbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>Ipython Cloud/Grid on Intrepid</title>
		<link>http://scipyed.wordpress.com/2009/04/18/ipython-cloudgrid-on-intrepid/</link>
		<comments>http://scipyed.wordpress.com/2009/04/18/ipython-cloudgrid-on-intrepid/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 19:54:47 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=22</guid>
		<description><![CDATA[Installing ipython for cloud/grid computing is a little bit different than the process one must go through for Gutsy/Hardy. From a completely fresh Ubuntu Intrepid install the following Ubuntu/debian packages are needed: $ sudo apt-get install build-essential libssl-dev python-setuptools python-dev From there we will use &#8220;easy_install&#8221; to get the relevent python modules we need to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=22&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Installing ipython for cloud/grid computing is a little bit different than the process one must go through for Gutsy/Hardy. From a completely fresh Ubuntu Intrepid install the following Ubuntu/debian packages are needed:</p>
<p>$ sudo apt-get install build-essential libssl-dev python-setuptools python-dev</p>
<p>From there we will use &#8220;easy_install&#8221; to get the relevent python modules we need to work with.</p>
<p>$  sudo easy_install foolscap nose pexpect pyopenssl sphinx</p>
<p>Then, becuase I am a bit paranoid, I download the ipython source and run it&#8217;s confgure option to make sure that it can find all the dependant libraries.</p>
<p>$ wget http://ipython.scipy.org/dist/ipython-0.9.1.tar.gz<br />
$ tar xfz ipython-0.9.1.tar.gz<br />
$ cd ipython-0.9.1/<br />
$ ./setup.py configure</p>
<p>As mentioned in a previous article, you ought to see something along the lines of:</p>
<pre>Twisted: 8.1.0
Foolscap: 0.3.2
OpenSSL: 0.8
sphinx: 0.5.1
pygments: 1.0
nose: 0.10.4
pexpect: 2.1</pre>
<p>Next we know the installer can find everything in the proper fashion, I install via easy_install (this makes upgrading easy later as new versions come out)</p>
<p>$ cd ..</p>
<p>$ rm ipython-0.9.1/<br />
$ sudo easy_install ipython</p>
<p>From there you should be up and running!</p>
<p>The following is a good test as to whether all capabilities are functioning properly: everything is functioning properly:</p>
<pre>$ ipcluster -n 4</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=22&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/04/18/ipython-cloudgrid-on-intrepid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>Compiling ipython for Cloud Computing Fun</title>
		<link>http://scipyed.wordpress.com/2009/03/03/compiling-ipython-for-cloud-computing-fun/</link>
		<comments>http://scipyed.wordpress.com/2009/03/03/compiling-ipython-for-cloud-computing-fun/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 22:44:13 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/?p=14</guid>
		<description><![CDATA[So ipython now has a powerful cloud computing environment built into it. Python is becoming a very common cloud computing platform. It is seen in Amazon&#8217;s compute cloud, and the Google App Engine is purely Python. Also notably, it seems that future versions of Ubuntu will ship with such capabilities! This post will hopefully tell [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=14&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So <a href="http://ipython.scipy.org/" target="_blank">ipython</a> now has a powerful <a href="http://en.wikipedia.org/wiki/Cloud_computing" target="_blank">cloud computing</a> environment built into it.  Python is becoming a very common cloud computing platform.  It is seen in <a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://aws.amazon.com/ec2/">Amazon&#8217;s compute cloud</a>, and the <a href="http://code.google.com/appengine/">Google App Engine</a> is purely Python.</p>
<p>Also notably, it seems that future versions of Ubuntu will ship with such <a href="http://www.webmonkey.com/blog/Ubuntu_Linux_Looks_to_the_Cloud_for__Jaunty_Jackalope_">capabilities!</a></p>
<p>This post will hopefully tell you everything you need to install similar capabilities and build a cloud of your own using ipython!</p>
<p>Installation on <a href="http://www.ubuntu.com/">Ubuntu</a> Gusty/Hardy/Intrepid:</p>
<p>First you need to get the various code bits that python modules will depend on:</p>
<pre>$sudo apt-get install libssl-dev python-setuptools</pre>
<p>This will install both the <a href="http://www.openssl.org/">openssl</a> crpytography libraries and the &#8220;<a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>&#8221; tool, that makes getting and updating python modules really effortless.  There is an ongoing battle between this utility and &#8220;<a href="http://pypi.python.org/pypi/pip">pip</a>&#8220;, but that discussion is well beyond the scope of our post today.  I perfer easy_install becuase it is exactly what is advertises.</p>
<p>Next up, we &#8220;easy_install&#8221; everything we need that ipython&#8217;s parallel capabilities will depend on:</p>
<pre>$sudo easy_install foolscap nose pexpect pyopenssl sphinx</pre>
<p>Depending on what you already have installed, this may take some time.</p>
<p>There are a lot of dependencies to ipython, so to make sure we got them all right, we grab the current ipython source:</p>
<pre>$mkdir ipython_build
$cd ipython_build
$wget http://ipython.scipy.org/dist/ipython-0.9.1.tar.gz
$tar xfz ipython-0.9.1.tar.gz
$cd ipython-0.9.1
$./setup.py config</pre>
<p>At this point ought to see something like:</p>
<pre>Zope.Interface: yes
Twisted: 8.1.0
Foolscap: 0.3.2
OpenSSL: 0.8
sphinx: 0.5.1
pygments: 1.0
nose: 0.10.4
pexpect: 2.1</pre>
<p>If you are missing something essential to ipython&#8217;s build, it will let you know :p  Now that we know we have everything necessary we can go ahead with either the typical build/install whatnot from this source directory, or simply:</p>
<pre>$cd ../..
$rm -rf ipython_build
$sudo easy_install -U ipython</pre>
<p>And you should be all set to go!</p>
<p>Under *nix distros the following is a good test as to whether everything is functioning properly:</p>
<pre>$ipcluster -n 4</pre>
<p>Based on what I have seen the OSX / Windows install ought to be fairly similar.  You might have to grab the openssl source and compile pyopenssl on you own, pointing the linker to the right directories.  If anyone has any luck doing this in OSX / Windows, let me know and I&#8217;ll post an update.  Some links that might be helpful ( <a href="http://foolscap.lothar.com/trac">foolscap</a> <a href="http://pypi.python.org/pypi/nose/">nose</a> <a href="http://pypi.python.org/pypi/pexpect">pexpect</a> <a href="http://pyopenssl.sourceforge.net/">pyopenssl</a> <a href="http://pypi.python.org/pypi/Sphinx">sphinx</a> <a href="http://www.openssl.org/source/">openssl-source</a>)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=14&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/03/03/compiling-ipython-for-cloud-computing-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>Pycuda Fun!</title>
		<link>http://scipyed.wordpress.com/2009/01/03/pycuda-fun/</link>
		<comments>http://scipyed.wordpress.com/2009/01/03/pycuda-fun/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 07:40:00 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[compile]]></category>
		<category><![CDATA[numpy]]></category>
		<category><![CDATA[pycuda]]></category>
		<category><![CDATA[pylab]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scipy]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/2009/01/03/pycuda-fun/</guid>
		<description><![CDATA[I recently built myself a shiny new computer equipped with a NVIDIA 260 at least partly to indulge in the occasional video game, but moreover for its CUDA abilities. Until a couple of weeks ago, I was under the impression that I was going to have to brush up my C/C++ skills, but thanks to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=6&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently built myself a shiny new computer equipped with a <a href="http://www.tomshardware.com/reviews/nvidia-gtx-280,1953.html">NVIDIA 260</a> at least partly to indulge in the occasional video game, but moreover for its <a href="http://www.nvidia.com/object/cuda_home.html#">CUDA</a> abilities.  Until a couple of weeks ago, I was under the impression that I was going to have to brush up my C/C++ skills, but thanks to a nice fellow named <a href="http://mathema.tician.de/aboutme">Andreas Klöckner</a>, I was able to inline some CUDA code into Python very elegantly.</p>
<p>Though the particular package (called <a href="http://mathema.tician.de/software/pycuda">pycuda</a>), is exceptionally well developed, it however does not allow you to escape understanding the GPU architecture and computing strategy underlying everything.  Correspondingly, I will talk a little about everything.  So without further ado, here is the first program I wrote with Python and CUDA working together:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td>
<pre><span style="color:#3333ff;">from</span> scipy <span style="color:#3333ff;">import</span> *
<span style="color:#3333ff;">from</span> scipy <span style="color:#3333ff;">import</span> misc
<span style="color:#3333ff;">from</span> pylab <span style="color:#3333ff;">import</span> *
<span style="color:#3333ff;">import</span> pycuda.autoinit
<span style="color:#3333ff;">import</span> pycuda.driver <span style="color:#3366ff;">as</span> drv
<span style="color:#3333ff;">import</span> time

<span style="color:#009900;">mod</span> = drv.SourceModule("""<span style="color:#cc33cc;">
__global__ void julia_iterate(float *a, float *b, float *max_iter)
</span><span style="color:#cc33cc;">{</span><span style="color:#cc33cc;">
  const int i = blockIdx.x * blockDim.x + threadIdx.x;</span><span style="color:#cc33cc;">
  float bounds = 16.0;</span>

<span style="color:#cc33cc;">  for(int iter = 0; iter &lt; </span><span><span style="color:#cc33cc;">max_iter[i]; iter++)<span style="color:#cc33cc;">
  </span></span></span><span style="color:#cc33cc;">{</span><span style="color:#cc33cc;">
    float new_a = (a[i] * a[i]) - (b[i] * b[i]) +.6;</span><span style="color:#cc33cc;">
    float new_b = (2 * a[i] * b[i])  - .2;</span><span style="color:#cc33cc;">
    a[i] = new_a;</span><span style="color:#cc33cc;">
    b[i] = new_b;</span><span style="color:#cc33cc;">
    if(abs((a[i]*a[i])+(b[i]*b[i])) &gt; bounds)</span><span style="color:#cc33cc;">
    {</span><span style="color:#cc33cc;">
      max_iter[i] = iter;</span><span style="color:#cc33cc;">
      break;</span><span style="color:#cc33cc;">
    }</span><span style="color:#cc33cc;">
  }</span><span style="color:#cc33cc;">
}</span>

<span style="color:#cc33cc;">__global__ void mandelbrot_iterate(float *a, float *b, float *max_iter)</span><span style="color:#cc33cc;">
{</span><span style="color:#cc33cc;">
  const int i = blockIdx.x * blockDim.x + threadIdx.x;</span><span style="color:#cc33cc;">
  float bounds = 16.0;</span><span style="color:#cc33cc;">
  float ai = 0;</span><span style="color:#cc33cc;">
  float bi = 0;</span><span style="color:#cc33cc;">
  for(int iter = 0; iter &lt; </span><span><span style="color:#cc33cc;">max_iter[i]; iter++)
  </span></span><span style="color:#cc33cc;">{</span><span style="color:#cc33cc;">
    float new_a = (ai * ai) - (bi * bi) + a[i];</span><span style="color:#cc33cc;">
    float new_b = (2 * ai * bi)  + b[i];</span><span style="color:#cc33cc;">
    ai = new_a;</span><span style="color:#cc33cc;">
    bi = new_b;</span><span style="color:#cc33cc;">
    if(abs((ai*ai)+(bi*bi)) &gt; bounds)</span><span style="color:#cc33cc;">
    {</span><span style="color:#cc33cc;">
      max_iter[i] = iter;</span><span style="color:#cc33cc;">
      break;</span><span style="color:#cc33cc;">
    }</span><span style="color:#cc33cc;">
  }
</span><span style="color:#cc33cc;">}</span>
""")

<span style="color:#009900;">mb</span> = <span style="color:#009900;">mod</span>.get_function("mandelbrot_iterate")

<span style="color:#009900;">shape</span> = (5000,5000)<span style="color:#009900;">pxls</span> = <span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">shape</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">[0] * </span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">shape</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">[1]

<span style="color:#009900;">x</span>, <span style="color:#009900;">y</span> = mgrid[-2:1:</span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">shape</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">[0]*1j,-1:1:</span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">shape</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">[1]*1j]<span style="color:#009900;">
x</span> = <span style="color:#009900;">x</span>.astype(float32)
<span style="color:#009900;">y</span> = <span style="color:#009900;">y</span>.astype(float32)
<span style="color:#009900;">
x</span> = <span style="color:#009900;">x</span>.flatten()<span style="color:#009900;">
y</span> = <span style="color:#009900;">y</span>.flatten()

<span style="color:#009900;">itr</span>  = ones_like(<span style="color:#009900;">x</span>) * 3000

<span style="color:#009900;">start_time</span> = time.time()
mb( drv.In(</span></span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">x</span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">), drv.In(</span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">y</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">), drv.InOut(</span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">itr</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">), \
    block=(500,1,1), grid = (50000,1))<span style="color:#3333ff;">

print</span> "CUDA iteration time:", time.time() - </span></span><span><span><span><span><span><span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">start_time</span></span></span></span></span></span></span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">

<span style="color:#009900;">itr</span> = <span style="color:#009900;">itr</span>.reshape(</span></span><span><span><span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#009900;">shape</span></span></span></span></span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">)<span style="color:#009900;">itr</span> = log(<span style="color:#009900;">itr</span>)

misc.imsave("test.png", <span style="color:#009900;">itr</span>.T)</span></span></pre>
</td>
</tr>
</tbody>
</table>
<p>The names of the CUDA functions are a bit of a giveaway to the final punch-image, but this is code for generating <a href="http://en.wikipedia.org/wiki/Mandelbrot_set">Mandelbrot</a> fractals.  (A <a href="http://en.wikipedia.org/wiki/Julia_set">Julia</a> example is in there too, but is unused for now)  What is wonderful about CUDA that thanks to its incredible paralellism, it takes more time to write the image to disk than it does for the actual computation!<br />
On my NVIDIA 260 it took 1.8 seconds to do 3000 iterations on 25,000,000 points! The super computer is personal again.</p>
<div style="text-align:center;"><a href="http://1.bp.blogspot.com/_1BIC6bxW-A0/SV8jVdimosI/AAAAAAAAAC8/5mCnq9hZUmw/s1600-h/test.png"><img style="display:block;text-align:center;cursor:pointer;width:378px;height:378px;margin:0 auto 10px;" src="http://1.bp.blogspot.com/_1BIC6bxW-A0/SV8jVdimosI/AAAAAAAAAC8/5mCnq9hZUmw/s400/test.png" border="0" alt="" /></a>[Click for larger image.]</div>
<p>It is a shame that the highest resolution blogger supports appears to be 1600&#215;1600.  The code above actually outputs a 5000&#215;5000 &#8220;.png&#8221; (More than 9 times the area featured here!)</p>
<p>So lets go through this all step by step to give some idea of how this all works:</p>
<p>First we are going to import all the various important libraries.</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td>
<pre><span style="color:#3333ff;">from</span> scipy <span style="color:#3333ff;">import</span> *
<span style="color:#3333ff;">from</span> scipy <span style="color:#3333ff;">import</span> misc<span style="color:#3333ff;">
from</span> pylab <span style="color:#3333ff;">import</span> *
<span style="color:#3333ff;">import</span> pycuda.autoinit
<span style="color:#3333ff;">import</span> pycuda.driver <span style="color:#3366ff;">as</span> drv<span style="color:#3333ff;">import</span> time</pre>
</td>
</tr>
</tbody>
</table>
<p>The following import is worth particular note in all this:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#3333ff;">import</span> pycuda.autoinit</td>
</tr>
</tbody>
</table>
<p>It automatically initializes (and checks for the proper setup) of your CUDA device.  There is typically code that goes into accomplishing this, so just having things setup on import is very handy. While there are provisions in pycuda to do the initialization with more control over the process, they will not be covered here.  If you have more than one CUDA device, or certain <a href="http://en.wikipedia.org/wiki/Scalable_Link_Interface">SLI</a> configurations using the autoinit import feature may not be the best choice.  If you don&#8217;t know what this means, it likely will not affect you.</p>
<p>Next up we come to the actual CUDA/C code that we are going to run on the GPU.  I am assuming a fair bit of knowledge here about the C programming language, particularly pointers, indexing, etc, but if you don&#8217;t already know about these things, they are worth learning!  You can find some catchup links <a href="http://www.google.com/search?q=learning+C&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=com.ubuntu:en-US:official&amp;client=firefox-a">here.</a></p>
<div style="text-align:left;">And with that, on to the big block:</div>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td>
<pre><span style="color:#009900;">mod</span> = drv.SourceModule("""<span style="color:#cc33cc;">
__global__ void julia_iterate(float *a, float *b, float *max_iter)</span><span style="color:#cc33cc;">
{
</span><span style="color:#cc33cc;"> const int i = blockIdx.x * blockDim.x + threadIdx.x;</span><span style="color:#cc33cc;">
 float bounds = 16.0;</span>

  <span style="color:#cc33cc;">for(int iter = 0; iter &lt;</span> <span><span style="color:#cc33cc;">max_iter[i]; iter++)
 </span></span><span><span style="color:#cc33cc;"> </span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;">{
</span><span style="color:#cc33cc;">    float new_a = (a[i] * a[i]) - (b[i] * b[i]) +.6;
   </span><span style="color:#cc33cc;"> float new_b = (2 * a[i] * b[i])  - .2;
   </span><span style="color:#cc33cc;"> a[i] = new_a;</span><span style="color:#cc33cc;">
    b[i] = new_b;</span><span style="color:#cc33cc;">
    if(abs((a[i]*a[i])+(b[i]*b[i])) &gt; bounds)
</span><span style="color:#cc33cc;">    {</span><span style="color:#cc33cc;">
      max_iter[i] = iter;
     </span><span style="color:#cc33cc;"> break;
</span><span style="color:#cc33cc;">    }</span><span style="color:#cc33cc;">
  }
</span><span style="color:#cc33cc;">}</span>

<span style="color:#cc33cc;">__global__ void mandelbrot_iterate(float *a, float *b,
                                   float *max_iter)</span><span style="color:#cc33cc;">
{</span><span style="color:#cc33cc;">
  const int i = blockIdx.x * blockDim.x + threadIdx.x;
</span><span style="color:#cc33cc;">  float bounds = 16.0;</span><span style="color:#cc33cc;">
  float ai = 0;</span><span style="color:#cc33cc;">
  float bi = 0;</span><span style="color:#cc33cc;">
  for(int iter = 0; iter &lt;</span></span> <span><span style="color:#cc33cc;">max_iter[i]; iter++)</span></span><span><span style="color:#cc33cc;">
</span></span><span style="color:#cc33cc;"><span style="color:#cc33cc;"><span style="color:#cc33cc;">  {</span><span style="color:#cc33cc;">
    float new_a = (ai * ai) - (bi * bi) + a[i];</span><span style="color:#cc33cc;">
    float new_b = (2 * ai * bi)  + b[i];</span><span style="color:#cc33cc;">
    ai = new_a;</span><span style="color:#cc33cc;">   bi = new_b;
  </span><span style="color:#cc33cc;">  if(abs((ai*ai)+(bi*bi)) &gt; bounds)</span><span style="color:#cc33cc;">
    {</span><span style="color:#cc33cc;">
      max_iter[i] = iter;</span><span style="color:#cc33cc;">
      break;</span><span style="color:#cc33cc;">
    }</span><span style="color:#cc33cc;">
  }
</span><span style="color:#cc33cc;">}</span></span></span>""")</pre>
</td>
</tr>
</tbody>
</table>
<p>The above code will compile the entire code string into a module accessible by pycuda. Pycuda ties the lifetime of objects on the GPU the the life of objects in the Python environment.</p>
<p>At the end of execution, all the GPU resident objects are cleaned up and deallocated appropriately.  Correspondingly, if you want to remove something from the GPU you can simply delete  the associated objects and cleanup will happen automagically.  We will see this again in the &#8220;drv.In&#8221;/&#8221;drv.Out&#8221; objects.</p>
<p>Now its time to talk about some CUDA features that are worth understanding.  There are two in particular that are worth note in this example:<br />
1.) The &#8220;__global__&#8221; keyword.  This is a directive that tells the CUDA compiler that this function is accessible from both the standard CPU and GPU realm of things.  We use it for a function that we want to have a handle on from outside the GPU context (like through<br />
pycuda).</p>
<p>2.) This line:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#6600cc;">const int i = blockIdx.x * blockDim.x + threadIdx.x;</span></td>
</tr>
</tbody>
</table>
<p>contains several variables that appear to be undefined.  They are not defined in the normal C sense, but are special CUDA objects defined in context which they are run.<br />
At this point we need to talk a little bit about the CUDA threading structure.  Coming from a largely interpreted language background, this was a bit difficult for me.  CUDA is ideally suited to the single operation, multiple data paradigm. Thusly it is _very_ good at things like fractals where you need to perform the same operation over and over on a single data set.</p>
<p>So, you need to conceptually break down your operation into single action that is performed on any number of data pieces.</p>
<p>There is two levels of threaded-ness in CUDA:<br />
1.) Operations that can occur in any order/concurrently within a single <a href="http://en.wikipedia.org/wiki/Arithmetic_logic_unit">ALU</a><br />
2.) The chunks which will be slit apart to and sent to different ALU&#8217;s which also occur in any order/concurrently.</p>
<p>These are referred to in the NVIDIA CUDA documentation (with excellent diagrams) as threads at the lowest level.  These threads are grouped into &#8220;blocks&#8221; of threads.  These &#8220;blocks&#8221; are organized in a Cartesian grouping referred to as a &#8220;grid&#8221;.  (Illustrated on pdf page 16 of <a href="http://developer.download.nvidia.com/compute/cuda/2_0/docs/NVIDIA_CUDA_Programming_Guide_2.0.pdf">here</a>)</p>
<p>Being a modeling guy, I tend to think of this as an actual Cartesian organization of shapes.  This particular example I imagine as as a vector of vectors (some number of vectors glued end to end).</p>
<p>So within your function, there is a way to identify your thread number, the size of your block, and what block number you are in.  This is accomplished by the following three internal variables respectively:</p>
<div style="text-align:center;"><span style="color:#009900;"> threadIdx</span><span style="color:#009900;"><br />
blockDim</span><span style="color:#009900;"><br />
blockIdx</span></div>
<p>Each of these is a structure containing variables pertaining to its dimensionality.  In our example, we have both mono-dimensional blocks, and and a mono-dimensional grid.</p>
<p>Correspondingly, based off of simple geometric calculations:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#6600cc;">const int i = blockIdx.x * blockDim.x + threadIdx.x;</span></td>
</tr>
</tbody>
</table>
<p>Will store in the variable &#8220;i&#8221;, the correct index that needs to be processed by a particular thread in a particular block.<br />
For example, the zeroth thread in the zeroth block will operate on the zeroth array index.  Or the zeroth thread in the first block will be offset by the one times the block dimension.</p>
<p>This gets a bit more complicated for multidimensional arrays, so we will stick to 1-d for this example.  More complex examples are seen in the CUDA documentation mentioned earlier.  But really it boils down to a function of:</p>
<div style="text-align:center;"><span style="color:#009900;">threadIdx(.x / .y / .z)</span></div>
<div style="text-align:center;"><span style="color:#009900;">blockDim</span><span style="color:#009900;">(.x / .y)</span><br />
<span style="color:#009900;">blockIdx</span><span style="color:#009900;">(.x / .y)</span></div>
<p>Derived from geometry of the arrays.  The remainder of the code within that Python text block is industry standard C to generate either a Mandelbrot or Julia fractal.  Alright, back to Python!</p>
<p>Next we get a handle to the actual function on the GPU:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#009900;">mb</span> = <span style="color:#009900;">mod</span>.get_function(&#8220;mandelbrot_iterate&#8221;)</td>
</tr>
</tbody>
</table>
<p>&#8220;mb&#8221; is now an object which is callable within our Python code to execute the function we have described!  Were getting there!!</p>
<p>Next we are going to generate a pair of vectors which are the real and imaginary component corresponding to all the points withing the interesting area of the Mandelbrot set.</p>
<p>We want a 5000&#215;5000 grid so:</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#009900;">shape</span> = (5000,5000)<br />
<span style="color:#009900;">pxls</span> = <span style="color:#009900;">shape</span>[0] * <span style="color:#009900;">shape</span>[1]</td>
</tr>
</tbody>
</table>
<p>Next, we use the scipy function &#8220;mgrid&#8221; to generate the indices, convert them to float32 (to match the precision of NVIDIA GPU&#8217;s), then flatten them into linear vectors.  We also define a linear vector of how many iterations we will maximally perform on each point. NB: All of these vectors are the same length!</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#009900;">x</span>, <span style="color:#009900;">y</span> = mgrid[-2:1:<span style="color:#009900;">shape</span>[0]*1j,-1:1:<span style="color:#009900;">shape</span>[1]*1j]<span style="color:#009900;">x</span> = <span style="color:#009900;">x</span>.astype(float32)</p>
<p><span style="color:#009900;">y</span> = <span style="color:#009900;">y</span>.astype(float32)</p>
<p><span style="color:#009900;">x</span> = <span style="color:#009900;">x</span>.flatten()</p>
<p><span style="color:#009900;">y</span> = <span style="color:#009900;">y</span>.flatten()</p>
<p><span style="color:#009900;">itr</span> = ones_like(<span style="color:#009900;">x</span>) * 3000</td>
</tr>
</tbody>
</table>
<div style="text-align:center;">If you want to play with zooming, the other values<br />
in the mgrid statement deal with the bounds of intrest.</div>
<p>Now we call the actual function that performs the calculations.  While doing this, several objects are instantiated by &#8220;drv.In&#8221; and &#8220;drv.InOut&#8221;.  These objects correspond to arrays of data that are resident on the GPU.  Notably also, their lifetime on the GPU is tied to their lifetime in the Python interpretor environment.  Therefore, instantiating them allocates their memory space on the GPU and copies the ndarray over.  Also, when the object is destroyed at the end of the statement, the memory is deallocated, and cleaned up appropriately on the GPU itself.</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#009900;">start_time</span> = time.time()<br />
<span style="color:#009900;">mb</span>( drv.In(<span style="color:#009900;">x</span>), drv.In(<span style="color:#009900;">y</span>), drv.InOut(<span style="color:#009900;">itr</span>), block=(500,1,1), grid = (50000,1))<br />
<span style="color:#3333ff;">print</span> &#8220;CUDA iteration time:&#8221;, time.time() &#8211; <span style="color:#009900;">start_time</span>, <span style="color:#009900;">pxls</span></td>
</tr>
</tbody>
</table>
<p>The difference between &#8220;drv.In&#8221;, &#8220;drv.Out&#8221;, and &#8220;drv.InOut&#8221; is fairly obvious, but using them appropriately insures that time is not wasted copying back and forth unnecessarily.</p>
<p>In here we specify the geometry of our blocks and the grid.  (Note that 500*50,000 is our pixel count)  These are hard coded in this example, but it is easy to imagine juggling these around to fit the size of the problem.   Notably, the dimensions of both the grid size and block size are bounded, however allow some _very_ large numbers.  There is some dark voojoo in the optimization of these variables to get the best speed out of your operation.  Read through the <a href="http://www.nvidia.com/object/cuda_develop.html">CUDA ducumentation</a> if you want to know more!</p>
<p>Last up, we reshape the data back into the 2-d ndarray in scipy.  I chose to log scale the coloring because it brings out the iteration difference nearest the edges for nice contrast.  Then we output a .png of the image!  (Using the &#8220;.T&#8221; orients the axes in those more familiar to us.)</p>
<table style="text-align:left;margin-left:auto;margin-right:auto;" border="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color:#009900;">itr</span> = <span style="color:#009900;">itr</span>.reshape(<span style="color:#009900;">shape</span>)<br />
<span style="color:#009900;">itr</span> = log(<span style="color:#009900;">itr</span>)<br />
misc.imsave(&#8220;test.png&#8221;, <span style="color:#009900;">itr</span>.T)</td>
</tr>
</tbody>
</table>
<p>Depending on the versions of python &#8220;misc.imsave&#8221; may or may not work for you.  You can also use &#8220;imshow()&#8221; and &#8220;savefig()&#8221; from matplotlib, but this has boarders or figure formatting you would have to kill to get a pure image.  The matplotlib colormap of &#8216;winter&#8217; (&#8220;cm.winter&#8221;) looks very nice with this particular view, but play around!  There is a lot of neat visualization fun you can have here!  I love playing with the alpha channel that <a href="http://www.pythonware.com/products/pil/">PIL</a> extends you (another part of scipy).</p>
<p>One last closing note, is that pycuda is not dependent on <a href="http://www.scipy.org/">scipy</a>, only <a href="http://numpy.scipy.org/">numpy</a> (which scipy sits atop), so you should be able to manage all of this without the heady overhead of scipy if you so desire!</p>
<p>Comments, concerns, and critiques all welcome!  I am new to this whole thing and wanted to put together a more detailed example than those available with <a href="http://documen.tician.de/pycuda/">the pycuda documentation</a>!  This in particular show you how to attack problems larger than one block size.</p>
<p>Next up, I am going to write a <a href="http://en.wikipedia.org/wiki/Successive_over-relaxation">SOR</a> solver with pycuda, so check back if that intrestes you!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=6&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2009/01/03/pycuda-fun/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>

		<media:content url="http://1.bp.blogspot.com/_1BIC6bxW-A0/SV8jVdimosI/AAAAAAAAAC8/5mCnq9hZUmw/s400/test.png" medium="image" />
	</item>
		<item>
		<title>pycuda</title>
		<link>http://scipyed.wordpress.com/2008/11/29/pycuda/</link>
		<comments>http://scipyed.wordpress.com/2008/11/29/pycuda/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 03:10:00 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/2008/11/29/pycuda/</guid>
		<description><![CDATA[So. I had my first successful open source contribution!! I was playing with pycuda to do some intense linear algebra via my sexy new Nvidia 260 GTX, when I ran into a python hitch. The newest version of CUDA on compilation outputs a slightly different file format that expected. Causing the Python to crash. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=4&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So.  I had my first successful open source contribution!!</p>
<p>I was playing with <a href="http://mathema.tician.de/software/pycuda">pycuda</a> to do some intense linear algebra via my sexy new <a href="http://www.tomshardware.com/reviews/nvidia-gtx-280,1953.html">Nvidia 260 GTX</a>, when I ran into a python hitch.</p>
<p>The newest version of <a href="http://www.nvidia.com/object/cuda_home.html#">CUDA</a> on compilation outputs a slightly different file format that expected.  Causing the Python to crash.  I fixed a tid-bit of regex and every thing started rolling!</p>
<p>Here is the reply I got from Andreas:</p>
<blockquote><p>Hi all,</p>
<p>Meawoppl reported (below) that PyCuda fails with CUDA 2.1 because nv made a whitespace change in the cubin files they write. First of all, a change like that shouldn&#8217;t be able to take PyCuda down, so I&#8217;ve made sure that even if metadata extraction fails, PyCuda doesn&#8217;t throw weird-looking exceptions.</p>
<p>Next, I&#8217;ve fixed the actual bug along the lines of what Meawoppl suggests. Since this bug may turn people away from PyCuda unnecessarily, I&#8217;ve released <a href="http://0.91.1./" target="_blank">0.91.1.</a></p>
<p>Happy hacking,<br />Andreas</p>
<p>Email:<br />On Mittwoch 26 November 2008, Matt G wrote:<br />   I found a silly little bug you might wanna know about:<br />Some nvcc builds generate &#8220;cubin&#8221; files that your regex fails to account for:</p>
<p>The line:<br />reg  = 4<br />(two spaces b/t &#8216;reg&#8217; and &#8216;=&#8217; causes the:</p>
<p>self.registers = int(re.search(&#8220;reg = ([0-9]+)&#8221;, cubin).group(1))</p>
<p>to return a None and thusly crash ungracefully.  Adding a strategic + to the regex seems to fix things:</p>
<p>self.registers = int(re.search(&#8220;reg += ([0-9]+)&#8221;, cubin).group(1))</p>
<p>I attached my &#8220;cubin&#8221; file so you can take a looksee.<br />Thanks for the awesome tools.<br />I am gonna be taking on some big CFD chores only possible with your help!</p>
<p>Thanks.<br />-Meawoppl</p>
<p> ps:<br />nvcc &#8211;version<br />Copyright (c) 2005-2007 NVIDIA Corporation<br />Built on Fri_Nov__7_06:20:13_PST_2008<br />Cuda compilation tools, release 2.1, V0.2.1221&gt;</p>
<p>NVIDIA 260 GTX</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=4&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2008/11/29/pycuda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing the Newest Numpy and Scipy on Hardy Heron</title>
		<link>http://scipyed.wordpress.com/2008/10/16/installing-the-newest-numpy-and-scipy-on-hardy-heron/</link>
		<comments>http://scipyed.wordpress.com/2008/10/16/installing-the-newest-numpy-and-scipy-on-hardy-heron/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 20:59:00 +0000</pubDate>
		<dc:creator>meawoppl</dc:creator>
				<category><![CDATA[compile scipy numpy source python setup]]></category>

		<guid isPermaLink="false">http://scipyed.wordpress.com/2008/10/16/installing-the-newest-numpy-and-scipy-on-hardy-heron/</guid>
		<description><![CDATA[Because I had quite a bit of trouble with this, I started a blog to provide the info to others! First, apt-get the dependencies: sudo apt-get install debhelper dpatch dpkg-dev fftw-dev g77 lapack3-dev libufsparse-dev libx11-dev netcdfg-dev python-all-dev python-central refblas3-dev sharutils swig subversion build-essential Next make a folder somewhere and cd into it.Pull down the latest [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=3&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Because I had quite a bit of trouble with this, I started a blog to provide the info to others!</p>
<p>First, apt-get the dependencies:</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">sudo</span> apt-get install <span class="blsp-spelling-error">debhelper</span> <span class="blsp-spelling-error">dpatch</span> <span class="blsp-spelling-error">dpkg</span>-<span class="blsp-spelling-error">dev</span> <span class="blsp-spelling-error">fftw</span>-<span class="blsp-spelling-error">dev</span> g77 <span class="blsp-spelling-error">lapack</span>3-<span class="blsp-spelling-error">dev</span> <span class="blsp-spelling-error">libufsparse</span>-<span class="blsp-spelling-error">dev</span> <span class="blsp-spelling-error">libx</span>11-<span class="blsp-spelling-error">dev</span> <span class="blsp-spelling-error">netcdfg</span>-<span class="blsp-spelling-error">dev</span> python-all-<span class="blsp-spelling-error">dev</span> python-central <span class="blsp-spelling-error">refblas</span>3-<span class="blsp-spelling-error">dev</span> <span class="blsp-spelling-error">sharutils</span> swig subversion build-essential</span></p>
<p>Next make a folder somewhere and <span class="blsp-spelling-error">cd</span> into it.<br />Pull down the latest versions of <span class="blsp-spelling-error">scipy</span> and <span class="blsp-spelling-error">numpy</span>:</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">svn</span> checkout http://svn.scipy.org/svn/numpy/trunk <span class="blsp-spelling-error">numpy</span></span><br /><span style="font-weight:bold;"><span class="blsp-spelling-error">svn</span> checkout http://svn.scipy.org/svn/scipy/trunk <span class="blsp-spelling-error">scipy</span></span></p>
<p>Build <span class="blsp-spelling-error">Numpy</span>:<br />Check to see if everything looks good:</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">cd</span> <span class="blsp-spelling-error">numpy</span></span><br /><span style="font-weight:bold;">python setup.<span class="blsp-spelling-error">py</span></span><br />(select Configure &#8211; 0)</p>
<p>See if all the libraries you will be needing are found.<br />The output is a bit confusing, but if you are missing something crucial, it will appear in red with a &#8220;Warning:&#8221; preface.</p>
<p><span style="font-weight:bold;">python setup.<span class="blsp-spelling-error">py</span></span><br />(select Build &#8211; 1)</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">sudo</span> python setup.<span class="blsp-spelling-error">py</span></span><br />(select Install &#8211; 2)</p>
<p>Next repeat this process for <span class="blsp-spelling-error">Scipy</span>:<br /><strong><span class="blsp-spelling-error">cd</span> ../scipy</strong></p>
<p><span style="font-weight:bold;">python setup.<span class="blsp-spelling-error">py</span></span><br />(select Configure &#8211; 0)</p>
<p>For some people, (<span class="blsp-spelling-error">Ubuntu</span> Hardy Heron x86) it will fail to find <span class="blsp-spelling-error">umfpack</span>.h resulting in a swig error<br />So first try:</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">UMFPACK</span>=&#8221;/<span class="blsp-spelling-error">usr</span>/include/<span class="blsp-spelling-error">suitesparse</span>/&#8221;</span></p>
<p>I think this a problem cause by the fact that the modern <span class="blsp-spelling-error">libsuitesparse</span> package (which contains <span class="blsp-spelling-error">umfpack</span>) has a different directory than <span class="blsp-spelling-error">scipy</span> is expecting for <span class="blsp-spelling-error">umfpack</span>.h.</p>
<p>If that doesn&#8217;t work, some people can get away with:<br /><span style="font-weight:bold;"><span class="blsp-spelling-error">UMFPACK</span> = &#8220;None&#8221;</span></p>
<p>Which will default to different routines for sparse matrix solution (about an order of magnitude slower depending on your architecture) If you don&#8217;t know what this means, either option should work fine for you.</p>
<p><span style="font-weight:bold;">python setup.<span class="blsp-spelling-error">py</span></span><br />(select Build &#8211; 1)</p>
<p><span style="font-weight:bold;"><span class="blsp-spelling-error">sudo</span> python setup.<span class="blsp-spelling-error">py</span></span><br />(select Install &#8211; 2)</p>
<p>Any you should be all set with brand spanking new <span class="blsp-spelling-error">scipy</span> and <span class="blsp-spelling-error">numpy</span> for epic mischief.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scipyed.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scipyed.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scipyed.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scipyed.wordpress.com&amp;blog=6160971&amp;post=3&amp;subd=scipyed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://scipyed.wordpress.com/2008/10/16/installing-the-newest-numpy-and-scipy-on-hardy-heron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a68fddb3d8299012e4bcdea5b23f2e5f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">meawoppl</media:title>
		</media:content>
	</item>
	</channel>
</rss>
