Tag Archives: CUDA

Setting up cudamat in Ubuntu Machine

cudamat is a python library that makes you available to use CUDA benefits from Python instead of intricate low level approaches. This interface uses also

Before follow these steps please make sure that you installed a working CUDA library.

  1. Download cudamat from
  2. Compile with 'make' in the root downloaded folder /path/to/cudamat
  3. Set the environment variables to include cudamat in PYTHONPATH to be able to imported by any script. Run followings in the command line.
     PYTHONPATH=$PYTHONPATH:/path/to/cudamat
     export PYTHONPATH
  4. You are ready to use cudamat.

Here is a simple code you might test;

 # -*- coding: utf-8 -*-
 import numpy as np
 import cudamat as cm
 cm.cublas_init()
 # create two random matrices and copy them to the GPU
 a = cm.CUDAMatrix(np.random.rand(32, 256))
 b = cm.CUDAMatrix(np.random.rand(256, 32))
 # perform calculations on the GPU
 c = cm.dot(a, b)
 d = c.sum(axis = 0)
 # copy d back to the host (CPU) and print
 print d.asarray()

Note: If you get any other path problem, it would be related to CUDA installation therefore check environment parameters need to be set for CUDA.

Share

Getting started to Thrust on source code...

Here I am sharing the code that I write while learning basics of the Thrust. It is self explanatory with its qualified comments.

You might just download the code here from my dropbox.

This code is crafted as I am learning THRUST Library and utilizing its great benefits with little effort on CUDA complexity. You might choose to download the code since I am so lazy to keep the code aligned below as it is pretty long. 🙁

Share

Intallation CUDA to Ubuntu 12.10 with Optimus Nvidia Cards

I installed Ubuntu 12.10 to my brand new machine but as always I started to deal lot of deriver problems coming around. Most consuming trouble was about the Nvidia drivers. I installed all kind of drivers suggested by the Additional Drivers tool and the Nvidia website but I cannot get my Graphic card working. After hours of investigation see that with the new generation notebooks with Nvidia cards there is a new technology called Optimus. With that system, new machines have two different graphic cards as the Intel's native one on the mother board and Nvidia Card. To prolong the battery life, Intel card is working for simple graphic rendering where as Nvidia comes into play with hard rendering problems so that machine can keep the battery life better in hours. However, Nvidia is deficient to provide a driver supporting new tech on Linux machines. As always solution is taken by the open source approach, Bumblebee driver interface is developed. In Continue reading Intallation CUDA to Ubuntu 12.10 with Optimus Nvidia Cards

Share