equinor / isar-turtlebot

ISAR implementation for the Turtlebot3 Waffle Pi
Eclipse Public License 2.0
2 stars 23 forks source link

Update docker compose from docker-compose, update how gpu is requested #137

Closed jonaspetersorensen closed 1 year ago

jonaspetersorensen commented 1 year ago

Docker has integrated docker-compose as a command under docker, ie docker compose --help. Docker has added an improved way of requesting capabilities like gpu. Ye olde days of runtime: nvidia has finally passed.

Examples:

# When using a dockerfile then request gpu directly via argument `--gpus=<ID | "all">`
docker run -it --rm --gpus=all cuda-test
# When using docker compose then request capabilities under the `deploy` tag
demo:
   build: something
   command: something
   deploy:
      resources:
         reservations:
            devices:
               - capabilities: [gpu]

This is the way.


(Not added to pull request, just a suggestion)

Finally, if you want to simplify start/stop of container(s) along with clean up of permissions, then consider using a shell script like this:

#!/bin/bash

#######################################################################################
### PURPOSE
###

# Let the user do the following with one simple command:
# 1. Build container
# 2. Get container running in a detached from the shell
# 3. Provide the container access to X11 on the host
# 4. Enter the container
# 5. ...And now the user can start playing around with the app :)

# After exiting the container...
# 6. Remove the container access to X11 on the host
# 7. Stop and remove container

docker compose up --build --detach
xhost +local:$(docker inspect --format='{{ .Config.Hostname }}' turtle_sim)
docker exec -it turtle_sim bash

xhost -local:$(docker inspect --format='{{ .Config.Hostname }}' turtle_sim)
docker compose down --volumes
jonaspetersorensen commented 1 year ago

Output from black:

would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/services/video_streamer.py
would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/turtlebot/step_handlers/driveto.py
would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/turtlebot/step_handlers/takeimage.py
would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/turtlebot/step_handlers/takethermalimage.py
would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/utilities/inspection_pose.py
would reformat /home/runner/work/isar-turtlebot/isar-turtlebot/src/isar_turtlebot/turtlebot/turtlebot.py

...I have not touched those files in this pull request, but I can lint them for you if you want?