Jetson/Installing ArrayFire

ArrayFire is a high performance software library for parallel computing with an easy-to-use API. Its array based function set makes parallel programming simple.

ArrayFire's multiple backends (CUDA, OpenCL and native CPU) make it platform independent and highly portable.

A few lines of code in ArrayFire can replace dozens of lines of parallel computing code, saving you valuable time and lowering development costs.

This page contains build instructions pertaining to the Jetson TK1 Board. The full build instructions can be found on the ArrayFire GitHub Wiki.

Getting ArrayFire
There are 2 ways to get ArrayFire:
 * Install Pre-built Libraries
 * Build ArrayFire From Source

Install Pre-built Libraries
Install the dependencies for ArrayFire

apt-get install build-essential cmake cmake-curses-gui apt-get install libfreeimage3 sudo apt-get install libatlas3gf-base libatlas-dev libfftw3-dev liblapacke-dev

You will also need to install GLFW 3. Follow these instructions to build it from source.

Download the Tegra K1 build of ArrayFire from http://arrayfire.com/download/.

This is a self extracting file that is very easy to install.

Once installed, follow the instructions on the Using on Linux page to see how to run the examples and incorporate ArrayFire into your projects.

Prerequisites for installing ArrayFire
Download & install the CUDA Toolkit by following the Installing CUDA instructions, since it is needed by ArrayFire.

The following packages are required to build ArrayFire from source code:
 * build-essential (includes installing gcc, g++)
 * git (>= 1.8)
 * cmake
 * cmake-curses-gui (Recommended)
 * libfreeimage-dev (Optional. Required for image IO functionality)

sudo apt-get install build-essential git cmake cmake-curses-gui libfreeimage-dev

The following packages are required for the CPU backend of ArrayFire
 * libatlas3gf-base
 * libatlas-dev
 * libfftw3-dev
 * liblapacke-dev

sudo apt-get install libatlas3gf-base libatlas-dev libfftw3-dev liblapacke-dev

For graphics enabled builds, install GLEW and GLFW. sudo apt-get install libglew-dev libglewmx-dev For GLFW, follow these instructions to build it from source.

The following packages are required for the CUDA backend of ArrayFire
 * Boost (We recommend installing all boost components, but you may choose to install selectively as listed in the GitHub Wiki page of ArrayFire)

sudo apt-get install libboost-all-dev

Download ArrayFire Source Code
Get ArrayFire from our GitHub repository.

git clone --recursive https://github.com/arrayfire/arrayfire.git

If you miss the --recursive option, run the following commands.

git submodule init git submodule update

Build and Install ArrayFire
cd /path/to/dir/arrayfire # where ArrayFire was cloned mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CPU=ON -DBUILD_CUDA=ON -DBUILD_OPENCL=OFF # Enables CPU and CUDA. Jetson TK1 does not support OpenCL. make -j4 # or number of threads of your choosing

You can also use the following CMake options
 * -DBUILD_GRAPHICS=OFF to disable graphics functionality and requirements
 * -DUSE_GLEWmx_STATIC=ON to enable static linking with GLEWmx

To install ArrayFire, select the install location (default = /usr/local) cd build cmake .. -DCMAKE_INSTALL_PREFIX=/your/install/dir make install # sudo may be required if installing to a system path

Running Tests and Examples
Run tests: cd /path/to/dir/arrayfire/build make test                     # runs all test ctest                         # runs all test ctest -R substring            # runs all tests that match the substring CTEST_OUTPUT_ON_FAILURE ctest # runs tests while printing output only if a test fails ./test/testname_backend       # runs single test with output Run examples (the output of the hello world example is shown below): cd /path/to/dir/arrayfire/build ./examples/example_backend
 * 1) Choose you preferred command

Get In Touch
Let us know if you have any issues via the ArrayFire GitHub Page or the ArrayFire Users Google Group.

The ArrayFire Forums are also available.

If you wish to email us, technical@arrayfire.com would the the way to contact us.

Verify Installation with Hello World
To run the Hello World example, do the following: cd /path/to/dir/arrayfire/build/examples/ ./helloworld_cuda

Successful output is shown below.

ArrayFire v3.1.0 (CUDA, 32-bit Linux, build eb821c6) Platform: CUDA Toolkit 6.5, Driver: CUDA Driver Version: 6050 [0] GK20A, 1743 MB, CUDA Compute 3.2 Create a 5-by-3 matrix of random floats on the GPU A [5 3 1 1] Offsets: [0 0 0 0] Strides: [1 5 15 15] 0.7402    0.4464     0.7762     0.9210     0.6673     0.2948     0.0390     0.1099     0.7140     0.9690     0.4702     0.3585     0.9251     0.5132     0.6814 Element-wise arithmetic B [5 3 1 1] Offsets: [0 0 0 0] Strides: [1 5 15 15] 2.1744   -1.9317     2.2006     2.2962    -2.1189     1.7905     1.5390    -1.6097     2.1549     2.3243     1.9531     1.8509     2.2987     1.9910     2.1299 Fourier transform the result C [5 3 1 1] Offsets: [0 0 0 0] Strides: [1 5 15 15] (10.6327,0.0000)         (-1.7162,0.0000)          (10.1267,0.0000)          (0.4689,0.4640)          (-2.2490,6.0028)          (0.1713,0.1441)          (-0.3491,-0.7454)          (-1.7221,-0.9727)          (0.2667,0.4886)          (-0.3491,0.7454)          (-1.7221,0.9727)          (0.2667,-0.4886)          (0.4689,-0.4640)          (-2.2490,-6.0028)          (0.1713,-0.1441) Grab last row c [1 3 1 1] Offsets: [4 0 0 0] Strides: [1 5 15 15] (0.4689,-0.4640)         (-2.2490,-6.0028)          (0.1713,-0.1441) Create 2-by-3 matrix from host data D [2 3 1 1] Offsets: [0 0 0 0] Strides: [1 2 6 6] 1.0000    3.0000     5.0000     2.0000     4.0000     6.0000 Copy last column onto first D [2 3 1 1] Offsets: [0 0 0 0] Strides: [1 2 6 6] 5.0000    3.0000     5.0000     6.0000     4.0000     6.0000 Sort A and print sorted array and corresponding indices vals [5 3 1 1] Offsets: [0 0 0 0] Strides: [1 5 15 15] 0.0390    0.1099     0.2948     0.7402     0.4464     0.3585     0.9210     0.4702     0.6814     0.9251     0.5132     0.7140     0.9690     0.6673     0.7762 inds [5 3 1 1] Offsets: [0 0 0 0] Strides: [1 5 15 15] 2         2          1          0          0          3          1          3          4          4          4          2          3          1          0

Congratulations! You are now ready to use ArrayFire!

Do More with ArrayFire
Our documentation page page contains a vast amount of information about the API and examples provided by ArrayFire.

Our blog contains the latest developments with ArrayFire and tips and tricks to get the most out of your code.

If you are doing something really cool with ArrayFire, give us a shout out at technical@arrayfire.com, and we will be more than happy to lend our support.

Uninstalling ArrayFire
Simply delete the contents of the installed folder. You will need to delete the following: /install/prefix/lib/libaf* /install/prefix/include/arrayfire.h /install/prefix/include/af/*.h