About

Ian Ozsvald picture

This is Ian Ozsvald's blog, I'm an entrepreneurial geek, a Data Science/ML/NLP/AI consultant, founder of the Annotate.io social media mining API, author of O'Reilly's High Performance Python book, co-organiser of PyDataLondon, co-founder of the SocialTies App, author of the A.I.Cookbook, author of The Screencasting Handbook, a Pythonista, co-founder of ShowMeDo and FivePoundApps and also a Londoner. Here's a little more about me.

High Performance Python book with O'Reilly View Ian Ozsvald's profile on LinkedIn Visit Ian Ozsvald's data science consulting business Protecting your bits. Open Rights Group

26 January 2010 - 14:01pyCUDA on Windows and Mac for super-fast Python math using CUDA

I’ve just started to play with pyCUDA which lets you run parallel math operations on a CUDA-compliant NVidia graphics card through Python.

Update – I’ve written a High Performance Python tutorial (July 2011, 55 pages) which covers pyCUDA and other technologies, you might find it useful.

CUDA stands for Compute Unified Device Architecture – it is an architecture that lets us program the Graphics Processing Unit (GPU) on a high powered graphics card to do scientific or graphical math calculations rather than the usual texture processing for games.  In essence it is a mini supercomputer that is specialised just for fast math operations – if you can figure out how to use it.

The goal is to off-load the CPU-intensive calculations for two of my clients (a physics company and a flood modelling company) to achieve 10* to 100* speed-ups using commodity graphics cards.

pyCUDA makes it easy to interactively program a CUDA device rather than hitting C++ code with the slow write/compile/debug loop.  Recent MacBooks (mine was bought in January 2009) have NVidia cards with CUDA-compatible devices built-in (mine is a 9400M).  For my desktop computer I have a 9800 GT (costing £100).

It turns out that this is bleeding-edge stuff – getting pyCUDA compiled on my MacBook and Win XP machine took some time (forum posts for Mac and Windows issues) thankfully the group is helpful and the wiki has an installation section for Windows, Mac and Linux and some reasonable documentation.

Right now I’ve got as far as running some of the demo code on my MacBook (showing a 5* speed-up over the CPU) and my desktop (showing a 30* speed-up over the CPU).  I’ll report more as I progress.

Update – pyCUDA works inside IPython too, lovely.

Update – I don’t have OpenGL working for gl_interop.py but as noted here you need “CUDA_ENABLE_GL = True” in siteconf.py and you need PyOpenGL installed.  When rebuilding my MSVC threw a hissy fit, it isn’t essential to my work so I’m skipping this demo.

Update – I’ve submitted a patch and two examples to the wiki (SimpleSpeedTest, Mandelbrot). I get 200* speed-ups on the speed test (using a for loop on a sin() calculation) and 5 to 20* speed-up on Mandelbrots (it seems to scale very well vs numpy with increasing dimensions).

Update – There are lots of interesting papers for CUDA surfacing like this one showing a 3* speed-up for voice recognition tasks (using CPU and GPU together) and yet another way to improve fluid dynamic simulations. This Tom’s 3D article gives a great write-up (starting with the history of audio cards) on where 3D is right now and how NVidia is beating ATI for scientific computing.

Books to read:

The following CUDA books will help you understand the basics of CUDA programming – I particularly like the first (Kirk and Hwu).


Ian applies Data Science as an AI/Data Scientist for companies in ModelInsight, sign-up for Data Science tutorials in London. Historically Ian ran Mor Consulting. He also founded the image and text annotation API Annotate.io, co-authored SocialTies, programs Python, authored The Screencasting Handbook, lives in London and is a consumer of fine coffees.

No Comments | Tags: Python

14 January 2010 - 11:26Come to my screencasting SkillSwap in Brighton on Jan 27th

On January 27th here in Brighton I’m co-running a SkillSwap evening, I’ll spend 45 minutes teaching screencasting (based on a Mac) and Andy White will spend 45 minutes teaching podcasting.  We’ll cover planning, recording, editing, distributing and mics between us.

We’re both aiming the talks at freelancers (so they can communicate better with clients) and small companies (for training, marketing and demos).  We’re also the authors of The Screencasting Handbook and Podcasting Unleashed.

I’ll cover at least these topics:

  • Free and commercial tools on a Mac (and Windows/Linux if requested)
  • Recording your first screencast with Jing and hosting it on the Web
  • Planning your screencast so it meets the needs of your audience
  • The differences between a sales/marketing screencast and a tutorial
  • Using ScreenFlow to record, edit and produce a screencast and then upload it to YouTube
  • Hosting your own screencast and other distribution options

If you bring a laptop then I can get you started with the free Jing so you can walk away with a recording and hosting solution for Mac and Windows.

If you’re in Brighton then the event is free, see details in Upcoming and sign-up on EventBrite. SkillSwap has been running for years – cheers to Nat and James for finding a spot for us.

Madgex will be sponsoring beer and nibbles, the atmosphere will be relaxed and friendly.  Nat is recording the audio for a podcast and I intend to record a video of the evening for distribution via Vimeo (but of course that won’t be the same as being there and being able to ask questions!).


Ian applies Data Science as an AI/Data Scientist for companies in ModelInsight, sign-up for Data Science tutorials in London. Historically Ian ran Mor Consulting. He also founded the image and text annotation API Annotate.io, co-authored SocialTies, programs Python, authored The Screencasting Handbook, lives in London and is a consumer of fine coffees.

1 Comment | Tags: Screencasting, The Screencasting Handbook