• Stars
    star
    795
  • Rank 57,274 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 9 years ago
  • Updated 9 months ago

Reviews

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

Repository Details

Python library for GPGPU on Raspberry Pi

PyVideoCore

This is work in progress project. Backward compatibility is not guaranteed.

PyVideoCore is a Python library for GPGPU on Raspberry Pi boards. The Raspberry Pi SoC integrates Broadcom VideoCore IV graphics core. It has 12 quad processor units (QPU) which is a dual-issue 16 way (4 way pipelined and 4 way true) SIMD processor. Read the following guide thoroughly to study its architecture.

Several QPU assemblers are written by pioneers (hermanhermitage, petewarden, elorimer and so on). There is also an implementation of OpenCL for QPU: VC4CL.

PyVideoCore's QPU assembler is different from theirs in terms of that its assembly language is implemented as an Internal DSL of Python language. This makes GPGPU programming on Raspberry Pi relatively easier in the sense that

  • You can put host programs and GPU side programs in a single Python script.
  • You can execute the program without ahead-of-time compilation.
  • You can utilize Python functionality, libraries and tools to organize GPU programs.

Requirements

  • Raspberry Pi Zero, 1, 2, or 3
  • Python 2 (>= 2.6) or Python 3
  • NumPy
  • rpi-vcsm ~= 3.0.0
  • ioctl-opt ~= 1.2
  • nose (if you want to run tests)

Installation

$ git clone https://github.com/nineties/py-videocore.git
$ cd py-videocore
$ python setup.py install

Note that PyVideoCore does not work with the CPU-side OpenGL graphics stack, so configure your pi to use the legacy (original non-GL desktop) driver by the sudo raspi-config command (it just comments out all the dtoverlay=vc4-kms-v3d and dtoverlay=vc4-fkms-v3d lines in /boot/config.txt).

Depending on your running kernel version, PyVideoCore allocates memory through /dev/vcsm or /dev/vcsm-cma, which are the devices of the VCSM (VideoCore shared memory service) and the VCSM-CMA (contiguous memory allocator) drivers, respectively. To access the devices, you need to belong to the video group or need to be the root user. If you choose the former, run the following command and re-login.

$ sudo usermod --append --groups video $USER

The plain VCSM driver allocates memory in the GPU-side memory, of which size can be configured by the gpu_mem=XXX option in /boot/config.txt (e.g. gpu_mem=128 for 128 MB). This can also be done via the sudo raspi-config command.

On the other hand, the VCSM-CMA driver allocates memory in the CPU-side CMA memory, of which size can be configured by the dtoverlay=cma,cma-XXX option in /boot/config.txt (e.g. dtoverlay=cma,cma-128 for 128 MB).

Nevertheless, VideoCore IV QPUs can access arbitrary portions of the main memory, which may make your system unstable and even break your pi, so beware of bugs in the programs.

Getting Started

$ python examples/hello_world.py

Running Tests

$ nosetests -v
  • 128MB or more GPU memory is required to pass tests. Failed some tests with 64MB or less.

Documentation

TBD

Tutorials

In japanese.

Records

  • Achieved 8GFlops with sgemm.

https://pbs.twimg.com/media/CWYjkH7U4AAh9VE.jpg

License

Code and documentation are released under MIT license


[1]Supplementary information and errata list.

More Repositories

1

py-videocore6

Python library for GPGPU programming on Raspberry Pi 4
Python
245
star
2

chainer-pose-proposal-net

Chainer implementation of Pose Proposal Networks
Python
117
star
3

qmkl

Math Kernel Library for VideoCore IV QPU
Python
68
star
4

qmkl6

BLAS library for VideoCore VI QPU (Raspberry Pi 4)
Python
66
star
5

dockworker

Docker daemon API client in Rust
Rust
61
star
6

rpi-vcsm

A Python driver for VideoCore Shared Memory (VCSM) of Raspberry Pi
Python
25
star
7

onnion

Python
22
star
8

msgpack-schema

A specification language for MessagePack data schema
Rust
17
star
9

actcast-support

13
star
10

chainer-hand-pose

Chainer implementation of Hand Pose Estimation 🎉
Python
13
star
11

onnigiri

Python
12
star
12

librpimemmgr

A memory manager for Raspberry Pi
C
11
star
13

nnoir

NN Optimization IR
Python
9
star
14

gatekeeper

Gatekeeper: A SOCKS5 Server written in Rust
Rust
5
star
15

rpi-mailbox

A rust interface to mailbox of RaspberryPi
Rust
5
star
16

actix-redis-cluster

Rust
5
star
17

docker-pytorch

Dockerfile
5
star
18

actcast-app-python

DEPRECATED: Python API for Actcast app
Python
4
star
19

docker-cross-rpi

Cross-compiling toolchain for Raspberry Pi 1, 2 and 3 using crosstool-NG
Dockerfile
4
star
20

kingtime-rs

Rust binding of King of Time API
Rust
3
star
21

dnn-flop-count

Python
3
star
22

docker-actcast-rpi-app-base

Actcast base image for the Raspberry Pi
Shell
3
star
23

actfw-raspberrypi

actfw's additional components for RaspberryPi
Python
3
star
24

actfw-core

Core components of actfw, independent of specific devices
Python
3
star
25

libdrm_v3d

A thin userland wrapper for the V3D DRM driver
C
2
star
26

chainer-graphics

Differential graphics operations for Chainer
Python
2
star
27

containerd.io-for-raspbian

containerd.io (supporting armv6l, armvl7) for raspbian
Dockerfile
2
star
28

docker-chainer

Docker image for Chainer, ChainerCV and other utilities with CUDA driver.
Dockerfile
2
star
29

actix-rate-limit

Rust
2
star
30

libvc4mem

A userland library for **my own** kernel driver
C
2
star
31

multi_object_tracker

Python Library for Multi Object Tracking
Python
2
star
32

action-s3-cache

Cache dependencies and build outputs to S3
TypeScript
2
star
33

actcast-app-examples

Examples of Actcast applications
Python
2
star
34

docker-netdistiller-builder

build environment
Dockerfile
1
star
35

docker-rust-stable

Dockerfile
1
star
36

qmkl_sys

A rust interface to qmkl
Rust
1
star
37

rpi-peri-regs

A Python driver for accessing peripheral memory on Raspberry Pi
Python
1
star
38

actcast-rekognition-demo

Python
1
star
39

librpicopy

Fast implementations of memcpy and memset for Raspberry Pi
C
1
star
40

actcast-api-py-script

Actcast APIを実行するPythonスクリプト
Python
1
star
41

docker-ce-for-raspbian-buster

Docker CE (supporting armv6l, armvl7) for raspbian buster
1
star
42

libv4l-sys

Rust FFI to the libv4l
Rust
1
star
43

actfw-gstreamer

actfw's additional components depending on GStreamer
Python
1
star
44

bcm_host-sys

An low level Rust interface to RaspberryPi firmware
Rust
1
star
45

tcp2socks

Proxy server converting TCP to SOCKS5
Rust
1
star