Simplify GPU detection in docker launch script (#2064)

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
This commit is contained in:
San 2025-01-07 16:58:28 +03:00 committed by GitHub
parent 2b529e57a0
commit b7c64a1aa4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,19 +1,12 @@
#!/bin/bash #!/bin/bash
# Launch an experiment using the docker gpu image # Launch an experiment using the docker gpu image
cmd_line="$@" cmd_line="$@"
echo "Executing in the docker (gpu image):" echo "Executing in the docker (gpu image):"
echo $cmd_line echo $cmd_line
# TODO: always use new-style once sufficiently widely used (probably 2021 onwards) # Using new-style GPU argument
if [ -x "$(which nvidia-docker)" ]; then NVIDIA_ARG="--gpus all"
# old-style nvidia-docker2
NVIDIA_ARG="--runtime=nvidia"
else
NVIDIA_ARG="--gpus all"
fi
docker run -it ${NVIDIA_ARG} --rm --network host --ipc=host \ docker run -it ${NVIDIA_ARG} --rm --network host --ipc=host \
--mount src=$(pwd),target=/home/mamba/stable-baselines3,type=bind stablebaselines/stable-baselines3:latest \ --mount src=$(pwd),target=/home/mamba/stable-baselines3,type=bind stablebaselines/stable-baselines3:latest \
bash -c "cd /home/mamba/stable-baselines3/ && $cmd_line" bash -c "cd /home/mamba/stable-baselines3/ && $cmd_line"