Skip to content

Commit a375fa4

Browse files
authored
feat(env): Add docker file. (#30)
1 parent c258ff8 commit a375fa4

File tree

8 files changed

+139
-52
lines changed

8 files changed

+139
-52
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ conda activate embodiedgen
3737
bash install.sh basic
3838
```
3939

40+
### ✅ Starting from Docker
41+
42+
We provide a pre-built Docker image on [Docker Hub](https://hub.docker.com/repository/docker/wangxinjie/embodiedgen) with a configured environment for your convenience. For more details, please refer to [Docker documentation](https://github.com/HorizonRobotics/EmbodiedGen/docker/README.md).
43+
44+
> **Note:** Model checkpoints are not included in the image, they will be automatically downloaded on first run. You still need to set up the GPT Agent manually.
45+
46+
```sh
47+
IMAGE=wangxinjie/embodiedgen:env_v0.1.x
48+
CONTAINER=EmbodiedGen-docker-${USER}
49+
docker pull ${IMAGE}
50+
docker run -itd --shm-size="64g" --gpus all --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged --net=host --name ${CONTAINER} ${IMAGE}
51+
docker exec -it ${CONTAINER} bash
52+
```
53+
4054
### ✅ Setup GPT Agent
4155

4256
Update the API key in file: `embodied_gen/utils/gpt_config.yaml`.
@@ -52,7 +66,7 @@ You can choose between two backends for the GPT agent:
5266
<h2 id="image-to-3d">🖼️ Image-to-3D</h2>
5367

5468
[![🤗 Hugging Face](https://img.shields.io/badge/🤗-Image_to_3D_Demo-blue)](https://huggingface.co/spaces/HorizonRobotics/EmbodiedGen-Image-to-3D) Generate physically plausible 3D asset URDF from single input image, offering high-quality support for digital twin systems.
55-
69+
(HF space is a simplified demonstration. For the full functionality, please refer to `img3d-cli`.)
5670
<img src="apps/assets/image_to_3d.jpg" alt="Image to 3D" width="900">
5771

5872
### ☁️ Service
@@ -79,7 +93,7 @@ img3d-cli --image_path apps/assets/example_image/sample_04.jpg apps/assets/examp
7993

8094
<h2 id="text-to-3d">📝 Text-to-3D</h2>
8195

82-
[![🤗 Hugging Face](https://img.shields.io/badge/🤗-Text_to_3D_Demo-blue)](https://huggingface.co/spaces/HorizonRobotics/EmbodiedGen-Text-to-3D) Create 3D assets from text descriptions for a wide range of geometry and styles.
96+
[![🤗 Hugging Face](https://img.shields.io/badge/🤗-Text_to_3D_Demo-blue)](https://huggingface.co/spaces/HorizonRobotics/EmbodiedGen-Text-to-3D) Create 3D assets from text descriptions for a wide range of geometry and styles. (HF space is a simplified demonstration. For the full functionality, please refer to `text3d-cli`.)
8397

8498
<img src="apps/assets/text_to_3d.jpg" alt="Text to 3D" width="900">
8599

docker/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM pytorch/pytorch:2.4.0-cuda11.8-cudnn9-devel
2+
LABEL maintainer="Horizon Robotics <xinjie.wang@horizon.auto>" \
3+
version="0.1.2" \
4+
description="Docker image for EmbodiedGen"
5+
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
git \
8+
bash \
9+
build-essential \
10+
ninja-build \
11+
libgl1-mesa-glx \
12+
libglib2.0-0 \
13+
libsm6 \
14+
libxext6 \
15+
libxrender1 \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# TORCH_CUDA_ARCH_LIST="8.0;8.9;9.0" -> A100/4090/H100
19+
ENV CUDA_HOME=/usr/local/cuda-11.8 \
20+
PATH=/usr/local/cuda-11.8/bin:$PATH \
21+
LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH \
22+
DEBIAN_FRONTEND=noninteractive \
23+
TORCH_CUDA_ARCH_LIST="8.0;8.9;9.0" \
24+
TCNN_CUDA_ARCHITECTURES=80,89,90
25+
26+
RUN useradd -m -s /bin/bash e_user
27+
WORKDIR /EmbodiedGen
28+
COPY . .
29+
RUN chown -R e_user:e_user /EmbodiedGen
30+
USER e_user
31+
32+
RUN conda create -n embodiedgen python=3.10.13 -y && \
33+
conda run -n embodiedgen bash install.sh
34+
35+
RUN /opt/conda/bin/conda init bash && \
36+
echo "conda activate embodiedgen" >> /home/e_user/.bashrc
37+
38+
CMD ["bash", "--login"]

docker/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Docker
2+
3+
## Getting Started with Our Pre-built Docker Image
4+
5+
We provide pre-built Docker image on [Docker Hub](https://hub.docker.com/repository/docker/wangxinjie/embodiedgen) that includes a configured environment for your convenience.
6+
7+
```sh
8+
IMAGE=wangxinjie/embodiedgen:env_v0.1.x
9+
CONTAINER=EmbodiedGen-docker-${USER}
10+
docker pull ${IMAGE}
11+
docker run -itd --shm-size="64g" --gpus all --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged --net=host --name ${CONTAINER} ${IMAGE}
12+
docker exec -it ${CONTAINER} bash
13+
# ref `EmbodiedGen/README.md` to get start.
14+
```
15+
16+
> **Note**: Model checkpoints are not included in the default image, they will be automatically downloaded on first run. Also, you still need to configure the GPT agent manually. See the [Setup GPT Agent](https://github.com/HorizonRobotics/EmbodiedGen?tab=readme-ov-file#-setup-gpt-agent) section for detailed instructions.
17+
18+
If you prefer an image with all model checkpoints, you can use `wangxinjie/embodiedgen:v0.1.x`. However, please note that this image is significantly larger. We recommend using the lighter image and allowing the models to download on demand.
19+
20+
21+
## Getting Started with Building from the Dockerfile
22+
You can also build your customized docker based on our Dockerfile.
23+
24+
```sh
25+
git clone https://github.com/HorizonRobotics/EmbodiedGen.git
26+
cd EmbodiedGen
27+
TAG=v0.1.2 # Change to the latest stable version.
28+
git checkout $TAG
29+
git submodule update --init --recursive --progress
30+
31+
docker build -t embodiedgen:$TAG -f docker/Dockerfile .
32+
```

embodied_gen/validators/quality_checkers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ def __call__(self, image_paths: str | Image.Image) -> float:
476476
)
477477
try:
478478
result = float(result.strip())
479-
except ValueError:
479+
except Exception as e:
480480
logger.error(
481-
f"Parser error: failed convert {result} to float, use default value {self.default_value}."
481+
f"Parser error: failed convert {result} to float, {e}, use default value {self.default_value}."
482482
)
483483
result = self.default_value
484484

install.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
88

99
source "$SCRIPT_DIR/install/_utils.sh"
1010
git config --global http.postBuffer 524288000
11-
# Patch submodule .gitignore to ignore __pycache__, only if submodule exists
12-
PANO2ROOM_PATH="$SCRIPT_DIR/thirdparty/pano2room"
13-
if [ -d "$PANO2ROOM_PATH" ]; then
14-
echo "__pycache__/" > "$PANO2ROOM_PATH/.gitignore"
15-
log_info "Added .gitignore to ignore __pycache__ in $PANO2ROOM_PATH"
16-
fi
1711

1812
log_info "===== Starting installation stage: $STAGE ====="
1913

@@ -22,6 +16,13 @@ if [[ "$STAGE" == "basic" || "$STAGE" == "all" ]]; then
2216
fi
2317

2418
if [[ "$STAGE" == "extra" || "$STAGE" == "all" ]]; then
19+
# Patch submodule .gitignore to ignore __pycache__, if submodule exists
20+
PANO2ROOM_PATH="$SCRIPT_DIR/thirdparty/pano2room"
21+
if [ -d "$PANO2ROOM_PATH" ]; then
22+
echo "__pycache__/" > "$PANO2ROOM_PATH/.gitignore"
23+
log_info "Added .gitignore to ignore __pycache__ in $PANO2ROOM_PATH"
24+
fi
25+
2526
bash "$SCRIPT_DIR/install/install_extra.sh"
2627
fi
2728

install/install_basic.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ set -e
33
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
44
source "$SCRIPT_DIR/_utils.sh"
55

6-
try_install "Installing flash-attn..." \
7-
"pip install flash-attn==2.7.0.post2 --no-build-isolation" \
8-
"flash-attn installation failed."
6+
PIP_INSTALL_PACKAGES=(
7+
"pip==22.3.1"
8+
"torch==2.4.0+cu118 torchvision==0.19.0+cu118 --index-url https://download.pytorch.org/whl/cu118"
9+
"xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu118"
10+
"flash-attn==2.7.0.post2 --no-build-isolation"
11+
"-r requirements.txt --use-deprecated=legacy-resolver"
12+
"utils3d@git+https://github.com/EasternJournalist/utils3d.git#egg=9a4eb15"
13+
"clip@git+https://github.com/openai/CLIP.git"
14+
"segment-anything@git+https://github.com/facebookresearch/segment-anything.git#egg=dca509f"
15+
"nvdiffrast@git+https://github.com/NVlabs/nvdiffrast.git#egg=729261d"
16+
"kolors@git+https://github.com/HochCC/Kolors.git"
17+
"kaolin@git+https://github.com/NVIDIAGameWorks/kaolin.git@v0.16.0"
18+
"git+https://github.com/nerfstudio-project/gsplat.git@v1.5.3"
19+
)
920

10-
try_install "Installing requirements.txt..." \
11-
"pip install -r requirements.txt --use-deprecated=legacy-resolver --default-timeout=60" \
12-
"requirements installation failed."
13-
14-
try_install "Installing kolors..." \
15-
"pip install kolors@git+https://github.com/HochCC/Kolors.git" \
16-
"kolors installation failed."
17-
18-
try_install "Installing kaolin..." \
19-
"pip install kaolin@git+https://github.com/NVIDIAGameWorks/kaolin.git@v0.16.0" \
20-
"kaolin installation failed."
21+
for pkg in "${PIP_INSTALL_PACKAGES[@]}"; do
22+
try_install "Installing $pkg..." \
23+
"pip install $pkg" \
24+
"$pkg installation failed."
25+
done
2126

2227
log_info "Installing diff-gaussian-rasterization..."
2328
TMP_DIR="/tmp/mip-splatting"
@@ -26,10 +31,6 @@ git clone --recursive https://github.com/autonomousvision/mip-splatting.git "$TM
2631
pip install "$TMP_DIR/submodules/diff-gaussian-rasterization"
2732
rm -rf "$TMP_DIR"
2833

29-
try_install "Installing gsplat..." \
30-
"pip install git+https://github.com/nerfstudio-project/gsplat.git@v1.5.3" \
31-
"gsplat installation failed."
32-
3334
try_install "Installing EmbodiedGen..." \
3435
"pip install triton==2.1.0 --no-deps && pip install -e ." \
3536
"EmbodiedGen installation failed."

install/install_extra.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
44
source "$SCRIPT_DIR/_utils.sh"
55

66
PYTHON_PACKAGES_NODEPS=(
7-
timm
8-
txt2panoimg@git+https://github.com/HochCC/SD-T2I-360PanoImage
9-
kornia
10-
kornia_rs
7+
"timm"
8+
"txt2panoimg@git+https://github.com/HochCC/SD-T2I-360PanoImage"
119
)
1210

1311
PYTHON_PACKAGES=(
14-
fused-ssim@git+https://github.com/rahul-goel/fused-ssim#egg=328dc98
15-
git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
16-
git+https://github.com/facebookresearch/pytorch3d.git@v0.7.7
17-
h5py
18-
albumentations==0.5.2
19-
webdataset
20-
icecream
21-
open3d
22-
pyequilib
23-
numpy==1.26.4
24-
triton==2.1.0
12+
"fused-ssim@git+https://github.com/rahul-goel/fused-ssim#egg=328dc98"
13+
"git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch"
14+
"git+https://github.com/facebookresearch/pytorch3d.git@stable"
15+
"kornia"
16+
"h5py"
17+
"albumentations==0.5.2"
18+
"webdataset"
19+
"icecream"
20+
"open3d"
21+
"pyequilib"
22+
"numpy==1.26.4"
23+
"triton==2.1.0"
2524
)
2625

2726
for pkg in "${PYTHON_PACKAGES_NODEPS[@]}"; do
@@ -30,6 +29,8 @@ for pkg in "${PYTHON_PACKAGES_NODEPS[@]}"; do
3029
"$pkg installation failed."
3130
done
3231

33-
try_install "Installing other Python dependencies..." \
34-
"pip install ${PYTHON_PACKAGES[*]}" \
35-
"Python dependencies installation failed."
32+
for pkg in "${PYTHON_PACKAGES[@]}"; do
33+
try_install "pip install $pkg..." \
34+
"pip install $pkg" \
35+
"$pkg installation failed."
36+
done

requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
torch==2.4.0+cu118
2-
torchvision==0.19.0+cu118
1+
torch==2.4.0
2+
torchvision==0.19.0
33
xformers==0.0.27.post2
44
pytorch-lightning==2.4.0
55
spconv-cu120==2.3.6
@@ -35,7 +35,7 @@ json-repair
3535
scikit-learn
3636
omegaconf
3737
tyro
38-
utils3d@git+https://github.com/EasternJournalist/utils3d.git#egg=9a4eb15
39-
clip@git+https://github.com/openai/CLIP.git
40-
segment-anything@git+https://github.com/facebookresearch/segment-anything.git#egg=dca509f
41-
nvdiffrast@git+https://github.com/NVlabs/nvdiffrast.git#egg=729261d
38+
pyquaternion
39+
shapely
40+
sapien==3.0.0b1
41+
typing_extensions==4.14.1

0 commit comments

Comments
 (0)