• Stars
    star
    418
  • Rank 103,620 (Top 3 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python bindings for ArrayFire: A general purpose GPU library.

ArrayFire Python Bindings

ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices. This project provides Python bindings for the ArrayFire library.

Documentation

Documentation for this project can be found over here.

Example

# Monte Carlo estimation of pi
def calc_pi_device(samples):
    # Simple, array based API
    # Generate uniformly distributed random numers
    x = af.randu(samples)
    y = af.randu(samples)
    # Supports Just In Time Compilation
    # The following line generates a single kernel
    within_unit_circle = (x * x + y * y) < 1
    # Intuitive function names
    return 4 * af.count(within_unit_circle) / samples

Choosing a particular backend can be done using af.set_backend(name) where name is either "cuda", "opencl", or "cpu". The default device is chosen in the same order of preference.

Getting started

ArrayFire can be installed from a variety of sources. Pre-built wheels are available for a number of systems and toolkits. These will include a distribution of the ArrayFire libraries. Currently, only the python wrapper is available on PyPI. Wrapper-only installations will require a separate installation of the ArrayFire C/C++ libraries. You can get the ArrayFire C/C++ library from the following sources:

Install the last stable version of python wrapper:

pip install arrayfire

Install a pre-built wheel for a specific CUDA toolkit version:

pip install arrayfire==3.8.0+cu112 -f https://repo.arrayfire.com/python/wheels/3.8.0/
# Replace the +cu112 local version with the desired toolkit

Install the development source distribution:

pip install git+git://github.com/arrayfire/arrayfire-python.git@master

Installing offline:

cd path/to/arrayfire-python
python setup.py install

Rather than installing and building ArrayFire elsewhere in the system, you can also build directly through python by first setting the AF_BUILD_LOCAL_LIBS=1 environment variable. Additional setup will be required to build ArrayFire, including satisfying dependencies and further CMake configuration. Details on how to pass additional arguments to the build systems can be found in the scikit-build documentation.

Post Installation:

If you are not using one of the pre-built wheels, you may need to ensure arrayfire-python can find the installed arrayfire libraries. Please follow these instructions to ensure that arrayfire-python can find the arrayfire libraries.

To run arrayfire tests, you can run the following command from command line.

python -m arrayfire.tests

Communication

Acknowledgements

The ArrayFire library is written by developers at ArrayFire LLC with contributions from several individuals.

The developers at ArrayFire LLC have received partial financial support from several grants and institutions. Those that wish to receive public acknowledgement are listed below:

Grants

This material is based upon work supported by the DARPA SBIR Program Office under Contract Numbers W31P4Q-14-C-0012 and W31P4Q-15-C-0008. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the DARPA SBIR Program Office.

More Repositories

1

arrayfire

ArrayFire: a general purpose GPU library.
C++
4,549
star
2

arrayfire-rust

Rust wrapper for ArrayFire
Rust
815
star
3

forge

High Performance Visualization
C++
226
star
4

arrayfire-js

ArrayFire.js - ArrayFire for Node.js
C++
120
star
5

arrayfire-ml

ArrayFire's Machine Learning Library.
C++
102
star
6

arrayfire-dotnet

.NET wrapper for ArrayFire
C#
78
star
7

androidcl

Sample app that runs OpenCL kernels to process camera feed on Android devices
C++
76
star
8

arrayfire-haskell

Haskell bindings to ArrayFire
Haskell
60
star
9

arrayfire-rb

Ruby wrapper for ArrayFire
C
37
star
10

arrayfire-java

Java wrapper for ArrayFire
Java
35
star
11

xilinx_demos

OpenCL Demos for Xilinx FPGAs
C++
31
star
12

arrayfire-fortran

Fortran wrapper for ArrayFire
Fortran
24
star
13

arrayfire-r

R wrapper for ArrayFire
R
22
star
14

arrayfire-go

Go bindings for arrayfire
Go
16
star
15

cuda_deployment_tutorial

Scripts to Deploy GPU Enabled Containers
Shell
13
star
16

arrayfire_opengl_interop

Code sample to show interoperability between ArrayFire and OpenGL.
C++
12
star
17

arrayfire-windows-scripts

Batch Scripts for Building ArrayFire on Windows
Batchfile
11
star
18

arrayfire-lua

Lua wrapper for ArrayFire
Lua
10
star
19

valhalla

Benchmarks for Open Source Libraries with Parallel Vector algorithms.
CMake
8
star
20

arrayfire-project-templates

Template Projects for ArrayFire
CMake
7
star
21

arrayfire-docker

Dockerfile for Building and Using ArrayFire https://github.com/arrayfire/arrayfire.git
Dockerfile
6
star
22

arrayfire-api-cheat-sheet

A quick reference of arrayfire library API; equivalent API in it's language wrappers and other math libraries.
6
star
23

ml_lab

Machine Learning Lab
C++
6
star
24

arrayfire-data

ArrayFire Test Data
5
star
25

ITK-ArrayFire-Bridge-Tutorial

Hands-on tutorial on how to combine ITK with ArrayFire http://www.itk.org
C++
5
star
26

arrayfire-benchmark

Benchmark software for ArrayFire
C++
5
star
27

arrayfire-d

D-lang bindings for arrayfire
D
4
star
28

afQuantumSim

ArrayFire Quantum Simulator
C++
4
star
29

threads

C++
4
star
30

d3m-arrayfire-primitives

DARPA D3M TA1 Accelerated Primitives
Python
3
star
31

assets

Assets for the ArrayFire documentation
3
star
32

freetype2

C
2
star
33

arrayfire-lisp

Lisp bindings for ArrayFire
2
star
34

arrayfire-extras

Add-on functionality for the ArrayFire library
2
star
35

arrayfire-binary-python-wrapper

A python thin wrapper for ArrayFire library
Python
2
star
36

arrayfire-torch

Torch wrapper for ArrayFire
1
star
37

arrayfire.github.io

ArrayFire documentation
HTML
1
star
38

af-sklearn-monkeypatch

Monkey-patch for scikit-learn with accelerated ArrayFire components.
Python
1
star