Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD NO_GPU option for docker in run.sh #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ pybind11-stubgen -o . --ignore-invalid=all pyridescence

### Docker

* Build: `docker build -t iridescence -f docker/ubuntu/Dockerfile .`
* Run: `bash docker/run.sh iridescence`
* Build:
`docker build -t iridescence -f docker/ubuntu/Dockerfile .`
* Run with gpu:
`bash docker/run.sh`
* Run without gpu:
`NO_GPU=1 bash docker/run.sh`
* Run if you don't approve the permission for docker:
`sudo bash docker/run.sh`
* Example of running `01_light_viewer_basic` with a specific option:
`NO_GPU=1 DOCKER_IMAGE="iridescence" DOCKER_CONTAINER="iridescence" bash docker/run.sh /root/iridescence/build/01_light_viewer_basic`

## Use Iridescence in your cmake project

Expand Down
58 changes: 50 additions & 8 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
#!/bin/bash
xhost + local:root
iname=${DOCKER_IMAGE:-"iridescence"} ## name of image
cname=${DOCKER_CONTAINER:-"iridescence"} ## name of container

sudo docker run -it --rm \
--gpus all \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev:/dev \
$@
SUDO_STRING=`groups|grep docker`
SUDO=""
if [ -z "$SUDO_STRING" ]; then
SUDO="sudo "
fi

# xhost - local:root
VAR="${@:-"bash"}"
if [ $# -eq 0 -a -z "$OPT" ]; then
OPT=-it
fi

if [ -z "$NO_GPU" ]; then
GPU_OPT='--gpus all,"capabilities=compute,graphics,utility,display"'
else
GPU_OPT=""
fi

NET_OPT="--net=host"

if [ -n "$USE_USER" ]; then
USER_SETTING=" -u $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro"
fi

xhost +si:localuser:root
rmimage=$(docker rm ${cname})

$SUDO docker run \
--privileged \
${OPT} \
${GPU_OPT} \
${NET_OPT} \
${USER_SETTING} \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--volume="/dev:/dev" \
--name=${cname} \
${iname} \
${VAR}


## capabilities
# compute CUDA / OpenCL アプリケーション
# compat32 32 ビットアプリケーション
# graphics OpenGL / Vulkan アプリケーション
# utility nvidia-smi コマンドおよび NVML
# video Video Codec SDK
# display X11 ディスプレイに出力
# all
Loading