Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Welcome to SGC-Ruby-CUDA

SGC-Ruby-CUDA implements Ruby bindings to Nvidia CUDA SDK. It provides easy access to CUDA-enabled GPU from a Ruby program.

SGC-Ruby-CUDA is incomplete in many ways. Currently, it supports only some crucial CUDA Driver and Runtime API functions. We hope to expand the coverage as much as possible.

SGC-Ruby-CUDA is tested on 64bit Fedora 14. We are looking forward to support Mac OSX. We have not tested it against 32bit Linux OS and Windows. We certainly wish to improve the code base to support multiple platforms in the future. We also welcome CUDA users to test it against their working environments.

Current development will focus on supporting CUDA Toolkit 4.0.

Check out {file:doc/features.rdoc} for the supported CUDA features. Also see {file:doc/devel.rdoc} for the latest development plan.

Fedora and the Infinity design logo are trademarks of Red Hat, Inc.

Linux is a registered trademark of Linus Torvalds.

NVIDIA, the NVIDIA logo, CUDA, GeForce, Quadro, and Tesla are trademarks or registered trademarks of NVIDIA Corporation in the U.S. and other countries.

Windows is a registered trademark of Microsoft Corporation in the United States and other countries.

Design philosophy

The Ruby bindings, Ruby CUDA API, which deal directly with Nvidia CUDA SDK C/C++ bindings retain the CUDA Driver and Runtime API in a systematic way whenever possible. This facilitates developers familiar with CUDA C who should be able to use SGC-Ruby-CUDA with minimum effort. At times, we may design the API to be more Ruby-like and let go unnecessary API structure in modern programming language.

We use Ruby-FFI as a bridge to call the CUDA C API. Ruby classes and methods to are built on top. The use of Ruby-FFI would ease the support of multiple Ruby interpretors.


  • Ruby (Tested with Ruby 1.9.2)

  • Ruby-FFI (Tested with Ruby-FFI 1.0.7)

  • CUDA Toolkit (Tested with CUDA Toolkit 4.0)

  • C++ compiler (Tested with GCC 4.6.0 but requires simple patch to CUDA Toolkit)

  • Yard (Tested with Yard 0.6.7, required for generating documentations)

How to get SGC-Ruby-CUDA

The SGC-Ruby-CUDA Ruby gem is available at and

# Install the gem with the following command.
$ gem install sgc-ruby-cuda


# Download the gem from the following URL and install.

The online documentations are available at the following:

The SGC-Ruby-CUDA git repository can be found in the following:

The master branch can be checked out with the following command:

git clone git:// sgc-ruby-cuda
git clone git:// sgc-ruby-cuda

The devel* branches may be checked out for a peep on the latest development. However, they are highly volatile and rebase may be applied for cleaner commits. The devel* branches serve as grace period before commits move into mainstream or master branches which are considered stable commits. This would minimize unnecessary fixing commits.

Getting started

# Setup the environment. Assuming the CUDA Toolkit is installed in
# the default path /usr/local/cuda.

# For 64bit Linux only:
export CPATH="/usr/local/cuda/include"
export LIBRARY_PATH="/usr/local/cuda/lib64"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
export PATH="/usr/local/cuda/bin:$PATH"

# For Mac OSX only:
export CPATH="/usr/local/cuda/include"
export LIBRARY_PATH="/usr/local/cuda/lib"
export DYLD_LIBRARY_PATH="/usr/local/cuda/lib:$DYLD_LIBRARY_PATH"
export PATH="/usr/local/cuda/bin:$PATH"

gem install ffi
cd sgc-ruby-cuda
rake test
# Check out the test cases in test/ on how to use Ruby CUDA API.

gem install yard
cd sgc-ruby-cuda
rake yard
# Check out the generated documentations in html/index.html with a browser.

How to contribute

  1. Create an account in github

  2. Fork this project SGC-Ruby-CUDA at

  3. Make changes and submit commits to your local repository.

  4. At your local repository, setup and send a pull request.

Ideally, a commit should do only one task. We like clean commits. Commits should be applied to the master branch.

How to file a bug report

Submit new issues at

Please provide information on the SGC-Ruby-CUDA version or the commit hash, OS platform, Ruby version, FFI version, how to reproduce the issue, the error messages.

Mailing list


SGC-Ruby-CUDA is released under the GNU GPLv3. See the file COPYING.

The Author

All kinds of feedbacks and bug reports are welcomed. Here is the author's email address:


NO LONGER MAINTAINED. Ruby bindings for using Nvidia CUDA







No packages published