containerized template to get up and running with a python installation containing the roboflow inference or inference-gpu module SDK.
-
the build scripts and tools in this template configuration will use
docker composeto spin up adebian-baseddockercontainer using the officialpython 3.10bullseyedockerimage that has theinference/inference-gpuSDK installed viapip. -
build configuration options to install either
inferenceorinference-gpuat theMakefilelevel. -
the docker compose specification is configured to allow pass-through for the
/dev/video0and/dev/video1device files in order to enable the container to access the webcam and/or other camera devices bound to those files. -
the docker compose specification has the requisite volume mounts needed to allow display forwarding outside of the container and into the host via
X11in order to allowopencvto display GUI windows.- /tmp/.X11-unix:/tmp/.X11-unix - $HOME/.Xauthority:/root/.Xauthority
make sure you have the following installed
- bash as the shell
- docker with the docker compose plugin
- (gnu) make
also make sure you have the X server running on the host
$ sudo Xcreate a .env file in the project's root and provide your Roboflow API key and model ID
ROBOFLOW_API_KEY=<YOUR_API_KEY_GOES_HERE>
ROBOFLOW_MODEL_ID=<YOUR_MODEL_ID_GOES_HERE>
type
$ make runin order to
- add
+local:dockerto the X server's access list - build the docker image with
inference(CPU is the defaultCOMPUTE_TYPE) - create the container
- start the container
execinto the container via abashsession
alternatively, type
$ make run COMPUTE_TYPE='gpu'in order to execute the same steps but build the docker image with inference-gpu instead if a GPU or any other kind of accelerator (OpenVINO, TensorRT) is available to be leveraged for faster inference
first, make sure you've exited out the container by typing
$ exitthen, type
$ make stopin order to
- stop the container
- remove the container
- remove the built docker image
alternatively, type
$ docker compose downif you just want to stop and remove the container but don't want to remove the built docker image (useful when you don't want to rebuild the entire image on each make start)
after you've started the container for the first time, you can move between the host (local) environment and the running container environment seamlessly:
- you can
execinto the already-running container again by just typing the samemake startinstruction mentioned before. - you can
exitout of the running container by just typingexitas mentioned before.