Skip to content

Commit

Permalink
Update Carla server
Browse files Browse the repository at this point in the history
  • Loading branch information
doganulus committed Jun 30, 2024
1 parent 44d61a5 commit 4d59d5d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 179 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/carlasim-release.yml

This file was deleted.

35 changes: 0 additions & 35 deletions carlasim/release/Dockerfile

This file was deleted.

99 changes: 48 additions & 51 deletions carlasim/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
ARG CARLA_VERSION=0.9.15
FROM ghcr.io/bounverif/carla:release-${CARLA_VERSION} as carla-release

FROM docker.io/library/ubuntu:22.04 as carla-server

ARG USER=bounverif
ARG USERGROUP=${USER}
ARG UID=1000
ARG GID=${UID}
FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04 AS carla-server

ARG CARLA_VERSION=0.9.15
ENV CARLA_VERSION=${CARLA_VERSION}
ARG CARLA_RELEASE_SERVER=https://carla-releases.s3.us-east-005.backblazeb2.com/Linux
ARG CARLA_RELEASE_TAR=CARLA_${CARLA_VERSION}.tar.gz
ARG CARLA_RELEASE_URL=${CARLA_RELEASE_SERVER}/${CARLA_RELEASE_TAR}
ARG CARLA_ADDITIONAL_MAPS_TAR=AdditionalMaps_${CARLA_VERSION}.tar.gz
ARG CARLA_ADDITIONAL_MAPS_URL=${CARLA_RELEASE_SERVER}/${CARLA_ADDITIONAL_MAPS_TAR}

RUN apt-get update && apt-get -y install --no-install-recommends \
ENV CARLA_VERSION=${CARLA_VERSION}
ENV CARLA_RELEASE_URL=${CARLA_RELEASE_URL}
ENV CARLA_ADDITIONAL_MAPS_URL=${CARLA_ADDITIONAL_MAPS_URL}

RUN set -eux; \
apt-get update; \
apt-get -y install --no-install-recommends \
tar \
wget \
gnupg2 \
software-properties-common \
; \
apt-get autoremove -y && apt-get clean -y

RUN mkdir -p /opt/carla-simulator; \
wget -qO- ${CARLA_RELEASE_URL} | tar xz --no-same-owner --no-same-permissions --mode 755 -C /opt/carla-simulator

RUN wget -qO- ${CARLA_ADDITIONAL_MAPS_URL} | tar xz --keep-newer-files --no-same-owner --no-same-permissions --mode 0755 -C /opt/carla-simulator

RUN set -eux; \
apt-get update; \
apt-get -qy install --no-install-recommends -o Dpkg::Options::="--force-confold" \
sudo \
supervisor \
python3 \
python3-pip \
Expand All @@ -20,53 +38,32 @@ RUN apt-get update && apt-get -y install --no-install-recommends \
libegl1 \
libvulkan1 \
vulkan-tools \
valgrind \
libomp5 \
xdg-user-dirs \
&& apt-get autoremove -y && apt-get clean -y

COPY --chown=root:root --chmod=755 --from=carla-release /carla_release /opt/carla-simulator/
COPY --chown=root:root --chmod=755 supervisord.conf /etc/supervisord.conf
COPY --chown=root:root --chmod=755 entrypoint.sh /etc/entrypoint.sh

RUN groupadd ${USERGROUP} -g ${GID} && useradd -ms /bin/bash ${USER} -g ${USERGROUP} -u ${UID} -G sudo

USER ${USER}
WORKDIR ${HOME}

RUN python3 -m pip install --user carla==${CARLA_VERSION}

ENV DISPLAY :0
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all
ENV XDG_RUNTIME_DIR /run/user/${UID}
ENV SDL_VIDEODRIVER=x11

ENV CARLA_SERVER_ARGS="-RenderOffScreen -ResX=1 -ResY=1 -nosound -quality-level=Low"
ENV CARLA_SERVER_MAP="Town05"

ENTRYPOINT ["/usr/bin/supervisord"]

EXPOSE 2000 2001 2002





; \
apt-get autoremove -y && apt-get clean -y

COPY --chown=root:root --chmod=0755 carla.sh /etc/carla/carla.sh

ARG USER=bounverif
ARG USERGROUP=${USER}
ARG UID=1000
ARG GID=${UID}

RUN groupadd ${USERGROUP} -g ${GID}; \
useradd -ms /bin/bash ${USER} -g ${USERGROUP} -u ${UID} -G sudo,video; \
printf "${USER} ALL= NOPASSWD: ALL\\n" >> /etc/sudoers

USER ${USER}
WORKDIR /home/${USER}

FROM docker.io/library/ubuntu:22.04 as carla-client
ENV DISPLAY=:0
ENV XDG_RUNTIME_DIR=/run/user/${UID}

ARG CARLA_VERSION=0.9.15
ENV CARLA_VERSION=${CARLA_VERSION}
RUN python3 -m pip install --user carla==${CARLA_VERSION}

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install \
python3 \
python3-pip \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/etc/carla/carla.sh"]

RUN python3 -m pip install --upgrade pip && \
python3 -m pip install numpy pygame carla==${CARLA_VERSION}
EXPOSE 2000 2001 2002
45 changes: 45 additions & 0 deletions carlasim/server/carla.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# set -x

# Set the default values of the environment variables used by the script
CARLA_SERVER_RENDERING=${CARLA_SERVER_RENDERING:-"OFFSCREEN"}
CARLA_SERVER_NO_SOUND=${CARLA_SERVER_NO_SOUND:-"true"}
CARLA_SERVER_FRAME_PER_SECOND=${CARLA_SERVER_FRAME_PER_SECOND:-25}
CARLA_SERVER_QUALITY_LEVEL=${CARLA_SERVER_QUALITY_LEVEL:-"Low"}
CARLA_SERVER_RPC_PORT=${CARLA_SERVER_RPC_PORT:-"2000"}
CARLA_SERVER_STREAMING_PORT=${CARLA_SERVER_STREAMING_PORT:-"2001"}
CARLA_SERVER_ADDITIONAL_ARGS=${CARLA_SERVER_ADDITIONAL_ARGS:-""}

CARLA_SERVER_ARGS=${CARLA_SERVER_ARGS:-"-fps=${CARLA_SERVER_FRAME_PER_SECOND}"}

gpu_count=$(/usr/bin/nvidia-smi -L | grep -i GPU | wc -l)
echo "$gpu_count NVIDIA GPU(s) found"

if [ "$gpu_count" -eq 0 ] && [ "$CARLA_SERVER_RENDERING" != "NONE" ]; then
echo "No NVIDIA GPU found, switching to CPU rendering"
CARLA_SERVER_RENDERING="NONE"
fi

if [ "$CARLA_SERVER_RENDERING" = "NONE" ]; then
CARLA_SERVER_RENDERING_ARGS="-nullrhi"
echo "No rendering mode selected"
elif [ "$CARLA_SERVER_RENDERING" = "OFFSCREEN" ]; then
CARLA_SERVER_RENDERING_ARGS="-RenderOffScreen -ResX=1 -ResY=1 -quality-level=${CARLA_SERVER_QUALITY_LEVEL}"
echo "Offscreen rendering mode selected"
elif [ "$CARLA_SERVER_RENDERING" = "SERVER" ]; then
CARLA_SERVER_RENDERING_ARGS="-quality-level=${CARLA_SERVER_QUALITY_LEVEL}"
echo "Server rendering mode selected"
fi

CARLA_SERVER_ARGS="${CARLA_SERVER_ARGS} ${CARLA_SERVER_RENDERING_ARGS}"

if [ "$CARLA_SERVER_NO_SOUND" ]; then
CARLA_SERVER_ARGS="${CARLA_SERVER_ARGS} -nosound"
fi

if [ "$CARLA_SERVER_ADDITIONAL_ARGS" ]; then
CARLA_SERVER_ARGS="${CARLA_SERVER_ARGS} ${CARLA_SERVER_ADDITIONAL_ARGS}"
fi

echo "Starting CarlaUE4 with ${CARLA_SERVER_ARGS}"
exec /opt/carla-simulator/CarlaUE4/Binaries/Linux/CarlaUE4-Linux-Shipping ${CARLA_SERVER_ARGS}
2 changes: 0 additions & 2 deletions carlasim/server/entrypoint.sh

This file was deleted.

16 changes: 0 additions & 16 deletions carlasim/server/supervisord.conf

This file was deleted.

0 comments on commit 4d59d5d

Please sign in to comment.