mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-16 09:09:48 +00:00
6057638fc1
The upstream libero __init__.py calls input() when ~/.libero/config.yaml is missing, which crashes in non-interactive Docker containers with EOFError. Pre-create the config with default paths at build time using importlib.util.find_spec to locate the module without triggering the problematic import. Made-with: Cursor
141 lines
6.1 KiB
Docker
141 lines
6.1 KiB
Docker
# Copyright 2025 The HuggingFace Inc. team. All rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Benchmark evaluation container — one image per benchmark, built via BENCHMARK arg.
|
|
#
|
|
# Supported values for BENCHMARK:
|
|
# libero — LIBERO suite (spatial / object / goal / 10 / 90)
|
|
# libero_plus — LIBERO-plus extended benchmark (requires robosuite, bddl, robomimic)
|
|
# robomme — RoboMME memory-augmented manipulation benchmark
|
|
# robocasa — RoboCasa kitchen composite-task benchmark
|
|
#
|
|
# Build:
|
|
# docker build --build-arg BENCHMARK=libero -f docker/Dockerfile.benchmark \
|
|
# -t lerobot-benchmark-libero .
|
|
#
|
|
# Run (interactive):
|
|
# docker run --gpus all --rm -it lerobot-benchmark-libero
|
|
# Run eval:
|
|
# docker run --gpus all --rm lerobot-benchmark-libero lerobot-eval --help
|
|
|
|
ARG CUDA_VERSION=12.4.1
|
|
ARG OS_VERSION=22.04
|
|
FROM nvidia/cuda:${CUDA_VERSION}-base-ubuntu${OS_VERSION}
|
|
|
|
ARG PYTHON_VERSION=3.12
|
|
ARG BENCHMARK=libero
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
MUJOCO_GL=egl \
|
|
PATH=/lerobot/.venv/bin:$PATH \
|
|
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
|
CUDA_VISIBLE_DEVICES=0 \
|
|
DEVICE=cuda \
|
|
BENCHMARK=${BENCHMARK}
|
|
|
|
# ── Base system deps (shared across all benchmarks) ───────────────────────────
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
software-properties-common build-essential git curl \
|
|
libglib2.0-0 libgl1-mesa-glx libegl1-mesa libegl1-mesa-dev \
|
|
libglew-dev libglfw3-dev libgl1-mesa-dri \
|
|
ffmpeg libusb-1.0-0-dev speech-dispatcher libgeos-dev portaudio19-dev \
|
|
cmake pkg-config ninja-build \
|
|
&& add-apt-repository -y ppa:deadsnakes/ppa \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
python${PYTHON_VERSION} \
|
|
python${PYTHON_VERSION}-venv \
|
|
python${PYTHON_VERSION}-dev \
|
|
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
|
|
&& mv /root/.local/bin/uv /usr/local/bin/uv \
|
|
&& useradd --create-home --shell /bin/bash user_lerobot \
|
|
&& usermod -aG sudo user_lerobot \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── Benchmark-specific system deps ────────────────────────────────────────────
|
|
# libero_plus: the `wand` Python package requires ImageMagick headers.
|
|
RUN case "${BENCHMARK}" in \
|
|
libero_plus) \
|
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
libmagickwand-dev \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* ;; \
|
|
esac
|
|
|
|
WORKDIR /lerobot
|
|
RUN chown -R user_lerobot:user_lerobot /lerobot
|
|
|
|
USER user_lerobot
|
|
|
|
ENV HOME=/home/user_lerobot \
|
|
HF_HOME=/home/user_lerobot/.cache/huggingface \
|
|
HF_LEROBOT_HOME=/home/user_lerobot/.cache/huggingface/lerobot \
|
|
TORCH_HOME=/home/user_lerobot/.cache/torch \
|
|
TRITON_CACHE_DIR=/home/user_lerobot/.cache/triton
|
|
|
|
RUN uv venv --seed --python python${PYTHON_VERSION}
|
|
|
|
# Copy only the dependency manifests first so Docker can cache this layer
|
|
# independently of source-code changes.
|
|
COPY --chown=user_lerobot:user_lerobot setup.py pyproject.toml README.md MANIFEST.in ./
|
|
COPY --chown=user_lerobot:user_lerobot src/ src/
|
|
|
|
ARG UNBOUND_DEPS=false
|
|
RUN if [ "$UNBOUND_DEPS" = "true" ]; then \
|
|
sed -i 's/,[[:space:]]*<[0-9\.]*//g' pyproject.toml; \
|
|
echo "Dependencies unbound:" && cat pyproject.toml; \
|
|
fi
|
|
|
|
# Install lerobot core + the selected benchmark extra.
|
|
# LIBERO-plus needs a dedicated install path because the upstream package is
|
|
# import-broken when installed via the extras chain alone.
|
|
RUN case "${BENCHMARK}" in \
|
|
libero_plus) \
|
|
PATH=/usr/bin:/bin:/lerobot/.venv/bin:$PATH /lerobot/.venv/bin/python -m pip install --no-cache-dir \
|
|
"hf-libero>=0.1.3,<0.2.0" \
|
|
"hf-egl-probe>=1.0.1" \
|
|
"transformers>=5.3.0,<6.0.0" \
|
|
"scipy>=1.14.0,<2.0.0" \
|
|
"bddl>=1.0.1,<2.0.0" \
|
|
"future" \
|
|
"easydict>=1.9" \
|
|
"wand" \
|
|
"scikit-image>=0.20.0" \
|
|
"gym>=0.25.0,<0.27.0" \
|
|
&& git clone --depth 1 https://github.com/sylvestf/LIBERO-plus.git /tmp/LIBERO-plus \
|
|
&& PATH=/usr/bin:/bin:/lerobot/.venv/bin:$PATH /lerobot/.venv/bin/python -m pip install --no-cache-dir --no-deps /tmp/LIBERO-plus \
|
|
&& /lerobot/.venv/bin/python -c "import pathlib, site; pathlib.Path(site.getsitepackages()[0], 'libero_plus_repo.pth').write_text('/tmp/LIBERO-plus\n')" \
|
|
&& /lerobot/.venv/bin/python -m pip install --no-cache-dir . \
|
|
&& /lerobot/.venv/bin/python -c "\
|
|
import os, yaml, importlib.util; \
|
|
root = os.path.dirname(importlib.util.find_spec('libero.libero').origin); \
|
|
d = dict(benchmark_root=root, bddl_files=os.path.join(root,'bddl_files'), \
|
|
init_states=os.path.join(root,'init_files'), datasets=os.path.join(root,'..','datasets'), \
|
|
assets=os.path.join(root,'assets')); \
|
|
cfg_dir = os.path.expanduser('~/.libero'); os.makedirs(cfg_dir, exist_ok=True); \
|
|
yaml.dump(d, open(os.path.join(cfg_dir,'config.yaml'),'w')); print('libero config created')" \
|
|
&& /lerobot/.venv/bin/python -c "from libero.libero import benchmark, get_libero_path; print('libero OK')" ;; \
|
|
*) \
|
|
uv pip install --no-cache ".[${BENCHMARK}]" ;; \
|
|
esac
|
|
|
|
# Triton requires its ptxas binary to be executable (NVIDIA-specific).
|
|
RUN if [ -f /lerobot/.venv/lib/python${PYTHON_VERSION}/site-packages/triton/backends/nvidia/bin/ptxas ]; then \
|
|
chmod +x /lerobot/.venv/lib/python${PYTHON_VERSION}/site-packages/triton/backends/nvidia/bin/ptxas; \
|
|
fi
|
|
|
|
# Copy full source (tests, examples, configs, etc.)
|
|
COPY --chown=user_lerobot:user_lerobot . .
|
|
|
|
CMD ["/bin/bash"]
|