1 unstable release

✓ Uses Rust 2018 edition

0.1.0 Jul 21, 2019

#53 in Machine learning

Apache-2.0

61KB
1.5K SLoC

OpenCL-accelerated 2D convolutions for Rust

Travis Build Status License: Apache-2.0 rust 1.34.0+ required

Documentation: crate docs (master)

This library provides 2D convolutions accelerated with OpenCL. Convolutions are particularly useful for deep learning tasks, such as image recognition; they are a basic building block for convolutional neural networks.

The library is intended mostly for quick-and-dirty hacking in deep learning research, in which one needs a separate spatial convolution primitive. Note that full-scale DL frameworks (TensorFlow, PyTorch, etc.) will most probably be a more robust and scalable tool for more high-level tasks.

Usage

See crate docs for the examples of usage.

Installing OpenCL

OpenCL has a variety of implementations. For quick testing, one may use POCL; it is open source and not tied to hardware (at the cost of being CPU-based, i.e., orders of magnitude slower than OpenCL implementations by GPU vendors). POCL may be installed from sources with the commands like these (showcased here for Ubuntu Xenial):

# Install utils for build
apt-get install build-essential cmake pkg-config libhwloc-dev zlib1g-dev
# Install OpenCL-related utils
apt-get install ocl-icd-libopencl1 ocl-icd-dev ocl-icd-opencl-dev clinfo
# Install LLVM / Clang from the official APT repository
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 
add-apt-repository 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main'
apt-get update
apt-get install clang-8 libclang-8-dev llvm-8 llvm-8-dev

# Get POCL sources
export POCL_VER=1.3 # latest stable version
curl -sSL "https://github.com/pocl/pocl/archive/v$POCL_VER.tar.gz" > pocl-$POCL_VER.tar.gz
tar xf "pocl-$POCL_VER.tar.gz"
# Build POCL from the sources
cd pocl-$POCL_VER
mkdir build && cd build
cmake -DWITH_LLVM_CONFIG=/usr/bin/llvm-config-8 -DCMAKE_INSTALL_PREFIX=/usr ..
make

# Verify installation
clinfo
# If successful, `clinfo` should display information about the POCL platform.

License

Licensed under the Apache 2.0 license.

Dependencies

~3.5MB
~57K SLoC