Get Started

ClojureCUDA uses native Nvidia GPU drivers, and CUDA toolkit, so it is very important that you do not skip any part of this guide.

How to Get Started

Usage

First use or require uncomplicate.clojurecuda.core and/or uncomplicate.clojurecuda.info and/or uncomplicate.clojurecuda.nvrtc in your namespace, and you’ll be able to call appropriate functions from the ClojureCUDA library.

(ns example
  (:use [uncomplicate.clojurecuda core info nvrtc]))

Now you can work with CUDA devices, contexts, streams, memory etc.

Here we initialize cuda and get the info of all devices.

(init)
(map info (map device (range (device-count))))

Overview and Features

ClojureCUDA is a Clojure library for High Performance Computing with CUDA, which supports Nvidia’s GPUs. If you need to create programs for AMD, Intel, or even Nvidia’s GPUs, or Intel’s and AMD’s CPUs, you probably need ClojureCL, ClojureCUDA’s OpenCL based cousin.

If you need higher-level high performance functionality, such as matrix computations, try Neanderthal.

Installation

Install CUDA Toolkit

To use ClojureCUDA, you must have an Nvidia GPU, and install appropriate GPU drivers. If you need to create your own CUDA kernels (you most probably do), you also need CUDA Toolkit. You can download both the drivers and the toolkit as one bundle from Nvidia’s CUDA Toolkit page. Please note that ClojureCUDA requires a minimal CUDA version, which is currently 8.0, so make sure that you have recently updated your drivers and the toolkit. If you use older drivers, some things might work, but some might not.

Add ClojureCUDA jar

The most straightforward way to include ClojureCUDA in your project is with Leiningen. Add the following dependency to your project.clj:

ClojureCUDA currently works out of the box on Linux, Windows, and OS X. For other plaforms, contact us.

Where to go next

Hopefully this guide got you started and now you’d like to learn more. CUDA programming requires a lot of knowledge about the CUDA parallel computing model, devices and specifics of parallel computations. The best beginner’s guide, in my opinion, is the OpenCL in Action book. It is not based on CUDA, but OpenCL (which is an open standard similar to CUDA supported by ClojureCL. Most books for CUDA are not as good as that one, but there are plenty of them, so you’ll find the one that suits your tastes (but I don’t know which one to recommend for beginners). I expect to build a comprehensive base of articles and references for exploring this topic, so please check the All Guides page from time to time. Of course, you should also check the ClojureCUDA API for specific details, and feel free to take a glance at the source while you are there.

Tell Us What You Think!

Please take some time to tell us about your experience with the library and this site. Let us know what we should be explaining or is not clear enough. If you are willing to contribute improvements, even better!