Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deeplearningais/CUV
Matrix library for CUDA in C++ and Python
https://github.com/deeplearningais/CUV
Last synced: 10 days ago
JSON representation
Matrix library for CUDA in C++ and Python
- Host: GitHub
- URL: https://github.com/deeplearningais/CUV
- Owner: deeplearningais
- Created: 2010-04-20T09:27:02.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2017-01-04T13:33:37.000Z (almost 8 years ago)
- Last Synced: 2024-07-31T22:46:52.578Z (3 months ago)
- Language: C++
- Homepage: www.ais.uni-bonn.de
- Size: 4.68 MB
- Stars: 196
- Watchers: 26
- Forks: 48
- Open Issues: 5
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
- awesome-gemm - CUV
README
CUV Documentation
0.9.201107041204
Summary
CUV is a C++ template and Python library which makes it easy to use NVIDIA(tm)
CUDA.Features
Supported Platforms:
• This library was only tested on Ubuntu Karmic, Lucid and Maverick. It uses
mostly standard components (except PyUBLAS) and should run without major
modification on any current linux system.Supported GPUs:
• By default, code is generated for the lowest compute architecture. We
recommend you change this to match your hardware. Using ccmake you can set
the build variable "CUDA_ARCHITECTURE" for example to -arch=compute_20
• All GT 9800 and GTX 280 and above
• GT 9200 without convolutions. It might need some minor modifications to
make the rest work. If you want to use that card and have problems, just
get in contact.
• On 8800GTS, random numbers and convolutions wont work.Structure:
• Like for example Matlab, CUV assumes that everything is an n-dimensional
array called "tensor"
• Tensors can have an arbitrary data-type and can be on the host (CPU-memory)
or device (GPU-memory)
• Tensors can be column-major or row-major (1-dimensional tensors are, by
convention, row-major)
• The library defines many functions which may or may not apply to all
possible combinations. Variations are easy to add.
• For convenience, we also wrap some of the functionality provided by Alex
Krizhevsky on his website (http://www.cs.utoronto.ca/~kriz/) with
permission. Thanks Alex for providing your code!Python Integration
• CUV plays well with python and numpy. That is, once you wrote your fast GPU
functions in CUDA/C++, you can export them using Boost.Python. You can use
Numpy for pre-processing and fancy stuff you have not yet implemented, then
push the Numpy-matrix to the GPU, run your operations there, pull again to
CPU and visualize using matplotlib. Great.Implemented Functionality
• Simple Linear Algebra for dense vectors and matrices (BLAS level 1,2,3)
• Helpful functors and abstractions
• Sparse matrices in DIA format and matrix-multiplication for these matrices
• I/O functions using boost.serialization
• Fast Random Number Generator
• Up to now, CUV was used to build dense and sparse Neural Networks and
Restricted Boltzmann Machines (RBM), convolutional or locally connected.Documentation
• Tutorials are available on http://www.ais.uni-bonn.de/~schulz/tag/cuv
• The documentation can be generated from the code or accessed on the
internet: http://www.ais.uni-bonn.de/deep_learning/doc/html/index.htmlContact
• We are eager to help you getting started with CUV and improve the library
continuously! If you have any questions, feel free to contact Hannes Schulz
(schulz at ais dot uni-bonn dot de) or Andreas Mueller (amueller at ais dot
uni-bonn dot de). You can find the website of our group at http://
www.ais.uni-bonn.de/deep_learning/index.html.Installation
Requirements
For C++ libs, you will need:
• cmake (and cmake-curses-gui for easy configuration)
• libboost-dev >= 1.37
• libblas-dev
• libtemplate-perl -- (we might get rid of this dependency soon)
• NVIDIA CUDA (tm), including SDK. We support versions 3.X and 4.0
• thrust library - included in CUDA since 4.0 (otherwise available from http:
//code.google.com/p/thrust/)
• doxygen (if you want to build the documentation yourself)For Python Integration, you additionally have to install
• pyublas -- from http://mathema.tician.de/software/pyublas
• python-nose -- for python testing
• python-devOptionally, install dependent libraries
• cimg-dev for visualization of matrices (grayscale only, ATM)
Obtaining CUV
You should check out the git repository
$ git clone git://github.com/deeplearningais/CUV.git
Installation Procedure
Building a debug version:
$ cd cuv-version-source
$ mkdir -p build/debug
$ cd build/debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
$ ccmake . # adjust paths to your system (cuda, thrust, pyublas, ...)!
# turn on/off optional libraries (CImg, ...)
$ make -j
$ ctest # run tests to see if it went well
$ sudo make install
$ export PYTHONPATH=`pwd`/src # only if you want python bindingsBuilding a release version:
$ cd cuv-version-source
$ mkdir -p build/release
$ cd build/release
$ cmake -DCMAKE_BUILD_TYPE=Release ../../
$ ccmake . # adjust paths to your system (cuda, thrust, pyublas, ...)!
# turn on/off optional libraries (CImg, ...)
$ make -j
$ ctest # run tests to see if it went well
$ sudo make install
$ export PYTHONPATH=`pwd`/src # only if you want python bindingsOn Debian/Ubuntu systems, you can skip the sudo make install step and instead
do$ cpack -G DEB
$ sudo dpkg -i cuv-VERSION.debBuilding the documentation
$ cd build/debug # change to the build directory
$ make docSample Code
We show two brief examples. For further inspiration, please take a look at the
test cases implemented in the src/tests directory.Pushing and pulling of memory
C++ Code:
#include
using namespace cuv;int main(void){
tensor h(256); // reserves space in host memory
tensor d(256); // reserves space in device memoryfill(h,0); // terse form
apply_0ary_functor(h,NF_FILL,0.f); // more verbosed=h; // push to device
sequence(d); // fill device vector with a sequenceh=d; // pull to host
for(int i=0;i
using namespace cuv;int main(void){
tensor C(2048,2048),A(2048,2048),B(2048,2048);fill(C,0); // initialize to some defined value, not strictly necessary here
sequence(A);
sequence(B);apply_binary_functor(A,B,BF_MULT); // elementwise multiplication
A *= B; // operators also work (elementwise)
prod(C,A,B, 'n','t'); // matrix multiplication
}Python Code
import cuv_python as cp
import numpy as np
C = cp.dev_tensor_float_cm([2048,2048]) # column major tensor
A = cp.dev_tensor_float_cm([2048,2048])
B = cp.dev_tensor_float_cm([2048,2048])
cp.fill(C,0) # fill with some defined values, not really necessary here
cp.sequence(A)
cp.sequence(B)
cp.apply_binary_functor(B,A,cp.binary_functor.MULT) # elementwise multiplication
B *= A # operators also work (elementwise)
cp.prod(C,A,B,'n','t') # matrix multiplicationThe examples can be found in the "examples/" folder under "python" and "cpp"
Generated on Mon Jul 4 2011 12:04:53 for CUV by doxygen 1.7.1