Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
June 6, 2021 08:28
January 12, 2018 15:12
November 8, 2015 11:46
November 24, 2015 21:33
December 28, 2015 18:36


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.


  • 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)


$ git clone
$ cd py-videocore
$ python 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/

Running Tests

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




In japanese.


  • Achieved 8GFlops with sgemm.


Code and documentation are released under MIT license

[1]Supplementary information and errata list.


Python library for GPGPU on Raspberry Pi







No releases published


No packages published