• Stars
    star
    245
  • Rank 165,304 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 5 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 library for GPGPU programming on Raspberry Pi 4

py-videocore6

A Python library for GPGPU programming on Raspberry Pi 4, which realizes assembling and running QPU programs.

For Raspberry Pi Zero/1/2/3, use nineties/py-videocore instead.

About VideoCore VI QPU

Raspberry Pi 4 (BCM2711) has a GPU named VideoCore VI QPU in its SoC. The basic instruction set (add/mul ALU dual issue, three delay slots et al.) remains the same as VideoCore IV QPU of Raspberry Pi Zero/1/2/3, and some units now perform differently. For instance, the TMU can now write to memory in addition to read, and it seems that the VPM DMA is no longer available.

Theoretical peak performance of QPUs are as follows.

  • VideoCore IV QPU @ 250MHz: 250 [MHz] x 3 [slice] x 4 [qpu/slice] x 4 [physical core/qpu] x 2 [op/cycle] = 24 [Gflop/s]
  • VideoCore IV QPU @ 300MHz: 300 [MHz] x 3 [slice] x 4 [qpu/slice] x 4 [physical core/qpu] x 2 [op/cycle] = 28.8 [Gflop/s]
  • VideoCore VI QPU @ 500MHz: 500 [MHz] x 2 [slice] x 4 [qpu/slice] x 4 [physical core/qpu] x 2 [op/cycle] = 32 [Gflop/s]

Requirements

py-videocore6 communicates with the V3D hardware through /dev/dri/card0, which is exposed by the DRM V3D driver. To access the device, you need to belong to video group or be root user. If you choose the former, run sudo usermod --append --groups video $USER (re-login to take effect).

Installation

You can install py-videocore6 directly using pip:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install python3-pip python3-numpy
$ pip3 install --user --upgrade pip setuptools wheel
$ pip3 install --user git+https://github.com/Idein/py-videocore6.git

If you are willing to run tests and examples, install py-videocore6 after cloning it:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install python3-pip python3-numpy libatlas3-base
$ python3 -m pip install --user --upgrade pip setuptools wheel
$ git clone https://github.com/Idein/py-videocore6.git
$ cd py-videocore6/
$ python3 -m pip install --target sandbox/ --upgrade . nose

Running tests and examples

In the py-videocore6 directory cloned above:

$ python3 setup.py build_ext --inplace
$ PYTHONPATH=sandbox/ python3 -m nose -v -s
$ PYTHONPATH=sandbox/ python3 examples/sgemm.py
==== sgemm example (1024x1024 times 1024x1024) ====
numpy: 0.6986 sec, 3.078 Gflop/s
QPU:   0.5546 sec, 3.878 Gflop/s
Minimum absolute error: 0.0
Maximum absolute error: 0.0003814697265625
Minimum relative error: 0.0
Maximum relative error: 0.13375753164291382
$ PYTHONPATH=sandbox/ python3 examples/summation.py
==== summaton example (32.0 Mi elements) ====
Preparing for buffers...
Executing on QPU...
0.01853448400004254 sec, 7241.514141947083 MB/s
$ PYTHONPATH=sandbox/ python3 examples/memset.py
==== memset example (64.0 MiB) ====
Preparing for buffers...
Executing on QPU...
0.01788834699993913 sec, 3751.5408215319367 MB/s
$ PYTHONPATH=sandbox/ python3 examples/scopy.py
==== scopy example (16.0 Mi elements) ====
Preparing for buffers...
Executing on QPU...
0.02768789600000332 sec, 2423.761776625857 MB/s
$ sudo PYTHONPATH=sandbox/ python3 examples/pctr_gpu_clock.py
==== QPU clock measurement with performance counters ====
500.529835 MHz

You may see lower performance without force_turbo=1 in /boot/config.txt.

References

More Repositories

1

py-videocore

Python library for GPGPU on Raspberry Pi
Python
795
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