Skip to main content

Python bindings for ArrayFire

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arrayfire-3.8.0.tar.gz (123.7 kB view details)

Uploaded Source

Built Distribution

arrayfire-3.8.0-py3-none-any.whl (72.8 kB view details)

Uploaded Python 3

File details

Details for the file arrayfire-3.8.0.tar.gz.

File metadata

  • Download URL: arrayfire-3.8.0.tar.gz
  • Upload date:
  • Size: 123.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.58.0 importlib-metadata/3.7.0 keyring/22.3.0 rfc3986/1.4.0 colorama/0.4.4 CPython/3.6.15

File hashes

Hashes for arrayfire-3.8.0.tar.gz
Algorithm Hash digest
SHA256 84221c66ca6049ddbfbd504a8d6ae5504491f0297f8ac4980dcc42732bb8dc6b
MD5 655f5fe26413590347aa248dbcad6c64
BLAKE2b-256 c7ad1875d346d22e7580455760c75158a4a6ddb23206ee95612c9ccfc71b6bc7

See more details on using hashes here.

File details

Details for the file arrayfire-3.8.0-py3-none-any.whl.

File metadata

  • Download URL: arrayfire-3.8.0-py3-none-any.whl
  • Upload date:
  • Size: 72.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.58.0 importlib-metadata/3.7.0 keyring/22.3.0 rfc3986/1.4.0 colorama/0.4.4 CPython/3.6.15

File hashes

Hashes for arrayfire-3.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 727aef6a6f7907bfc0cbdc81787b7c1b570c69d4e9c74061221cc7c378306ac2
MD5 062178decf0794b16f8261b4f321a8aa
BLAKE2b-256 284b48aa82d8c273a2e224a548a53b961d3f7474d3fc5185bbefb7bcf70e413a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page