Code Maven

Search for '{{search_term}}'

Welcome to the Code Maven!

Programming Exercises for any language.

For now, just read the articles...

If you want to make sure you don't miss any new articles, you can subscribe to the Code Maven newsletter, follow via atom feed, Twitter, or even my Google+ account.

Showing speed improvement using a GPU with CUDA and Python with numpy on Nvidia Quadro 2000D

I just installed Linux on an old computer that used to be powerful that has a Nvidia Quadro 2000D GPU. I wanted to see how to use the GPU to speed up computation done in a simple Python program. It took me some time and some hand holding to get there. Let me share the journey and the results.

In a nutshell: Using the GPU has overhead costs. If the computation is not heavy enough, then the cost (in time) of using a GPU might be larger than the gain. On the other hand if the computation is heavy, you can see a huge improvement in speed.


Showing speed improvement using a GPU with CUDA and Python with numpy on Nvidia Quadro 2000D


Show number of files in several directory trees using Shell

We already know how to Show number of files in a single directory tree using Shell, but what if given a directory, we would like to know the number of files in each one of its subdirectories separately?


Show number of files in several directory trees using Shell


Show number of files in a directory tree using Shell

Given a directory tree such as in the following example, we would like to know

  1. How many files are in it?
  2. How many files are in each one of the subdirectories?

groups/
  all.txt
  people/
    John.txt
    Jane.txt
  maskots/
    Foo.txt
    Bar.txt
  other -> maskots

All that using the Unix/Linux Shell.


Show number of files in a directory tree using Shell