At the moment I'm building a Kivy application to control custom hardware that opens and closes lockers. To accomplish this, I'm using a Raspberry Pi 3B+ along with a custom 10" touchscreen which is connected to my raspberry. The OS I'm using is Raspberry Pi OS (32-bit). I've followed all the steps to install Kivy detailed in Installing Kivy and thus installed the pre-compiled wheel. Everything works perfectly, but it seems I cant get my application hardware accelerated.
When I try to run my App I see the following:
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'3.1 Mesa 20.3.5'>
[INFO ] [GL ] OpenGL vendor <b'Mesa/X.org'>
[INFO ] [GL ] OpenGL renderer <b'llvmpipe (LLVM 11.0.1, 128 bits)'>
[INFO ] [GL ] OpenGL parsed version: 3, 1
[INFO ] [GL ] Shading version <b'1.40'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
According to this page it means that my application is not hardware accelerated.
So following the steps detailed there I used groups <user> to check if my user is in the render group, which it is:
<user>: <user> adm dialout cdrom sudo audio video plugdev games users input render netdev spi i2c gpio lpadmin docker
I've tried several combinations by setting the KIVY_GL_BACKEND and KIVY_WINDOW, but nothing works. At the moment I'm using the following function to start my application (haven't set my environment variables yet, but will do so in the future):
def initialize(self):
if os.environ.get('DISPLAY','') == '':
os.environ.__setitem__('DISPLAY', ':0.0')
os.environ['KIVY_GL_BACKEND'] = 'sdl2'
os.environ['KIVY_WINDOW'] = 'sdl2'
And use the following lines to make my application maximized:
from kivy.config import Config
Config.set('graphics', 'fullscreen', 'auto')
How can I make it so my application is hardware accelerated?
Update 1:
Reinstalled a 32-bit version of the raspberry pi os (with desktop).
I've tried installing the required libraries: sudo apt-get install python3-pip build-essential git python3 python3-dev ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev. I've then ran python -m pip install "kivy[base]" kivy_examples --no-binary kivy to build kivy from source. I then removed SDL2 using sudo apt-get -y remove libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev and followed the instructions to install SDL2, SDL2_image, SDL2_mixer, SDL2_ttf and used the command sudo ldconfig -v to update the dynamic library cache, checked the groups again and see my user is in the render group, and then ran a simple kivy app:
import kivy
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
which, in turn presented me again with:
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'3.1 Mesa 20.3.5'>
[INFO ] [GL ] OpenGL vendor <b'Mesa/X.org'>
[INFO ] [GL ] OpenGL renderer <b'llvmpipe (LLVM 11.0.1, 128 bits)'>
[INFO ] [GL ] OpenGL parsed version: 3, 1
[INFO ] [GL ] Shading version <b'1.40'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Update 2:
- Went into
sudo raspi-config - Went into '1 System Options Configure system settings'
- Choose the option 'S5 Boot / Auto Login Select boot into desktop or to command line'
- Choose the option 'B2 Console Autologin Text console, automatically logged in as '' user'.
- Rebooted into the headless console and re-ran the small test script from Update 1.
- I got greeted by the following:
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'2.1 Mesa 20.3.5'>
[INFO ] [GL ] OpenGL vendor <b'Broadcom'>
[INFO ] [GL ] OpenGL renderer <b'VC4 V3D 2.1'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20'>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
- Profit!