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.
- Download cudamat from
- Compile with ‘make’ in the root downloaded folder /path/to/cudamat
- 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
- 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.