Giter Club home page Giter Club logo

arrayfire-python's Introduction

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.

Example

import arrayfire as af

# Display backend information
af.info()

# Generate a uniform random array with a size of 5 elements
a = af.randu(5, 1)

# Print a and its minimum value
af.display(a)

# Print min and max values of a
print("Minimum, Maximum: ", af.min(a), af.max(a))

Sample outputs

On an AMD GPU:

Using opencl backend
ArrayFire v3.0.1 (OpenCL, 64-bit Linux, build 17db1c9)
[0] AMD     : Spectre
-1- AMD     : AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G

[5 1 1 1]
0.4107
0.8224
0.9518
0.1794
0.4198

Minimum, Maximum:  0.17936542630195618 0.9517996311187744

On an NVIDIA GPU:

Using cuda backend
ArrayFire v3.0.0 (CUDA, 64-bit Linux, build 86426db)
Platform: CUDA Toolkit 7, Driver: 346.46
[0] Tesla K40c, 12288 MB, CUDA Compute 3.5
-1- GeForce GTX 750, 1024 MB, CUDA Compute 5.0

Generate a random matrix a:
[5 1 1 1]
0.7402
0.9210
0.0390
0.9690
0.9251

Minimum, Maximum:  0.039020489901304245 0.9689629077911377

Fallback to CPU when CUDA and OpenCL are not availabe:

Using cpu backend
ArrayFire v3.0.0 (CPU, 64-bit Linux, build 86426db)

Generate a random matrix a:
[5 1 1 1]
0.0000
0.1315
0.7556
0.4587
0.5328

Minimum, Maximum:  7.825903594493866e-06 0.7556053400039673

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

Requirements

Currently, this project is tested only on Linux and OSX. You also need to have the ArrayFire C/C++ library installed on your machine. You can get it from the following sources.

Please check the following links for dependencies.

Getting started

Install the last stable version:

pip install arrayfire

Install the development version:

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

Installing offline

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

Please follow these instructions to ensure the arrayfire-python can find the arrayfire libraries.

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.

arrayfire-python's People

Contributors

filipemaia avatar pavanky avatar shehzan10 avatar syurkevi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.