Skip to content

Docker Compose #75

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

Open
wants to merge 3 commits into
base: main
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
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This Dockerfile uses the nvidia cuda container but will work without cuda too

FROM nvidia/cuda:12.1.0-devel-ubuntu20.04
ENV CUDAARCHS='60'
ENV TRIMESH_VERSION='2020.03.04'
ENV CMAKE_VERSION='3.20.4'

WORKDIR /installation/

RUN apt update
RUN apt install -y --no-install-recommends apt-utils
RUN apt install -y build-essential libglm-dev libgomp1 git mesa-common-dev libglu1-mesa-dev libxi-dev wget ninja-build

WORKDIR /installation/cuda_voxelizer

COPY . .

RUN wget -q -O ./cmake-install.sh https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh
RUN chmod u+x ./cmake-install.sh
RUN mkdir /cmake
RUN ./cmake-install.sh --skip-license --prefix=/cmake

WORKDIR /installation/
RUN git clone --single-branch --depth 1 -b ${TRIMESH_VERSION} https://github.com/Forceflow/trimesh2.git trimesh2
WORKDIR /installation/trimesh2
RUN pwd
RUN make all -j $(nproc)

ENV PATH="${PATH}:$HOME"/cmake/bin

WORKDIR /installation/cuda_voxelizer

RUN cmake -GNinja \
-DTrimesh2_INCLUDE_DIR="/installation/trimesh2/include" \
-DTrimesh2_LINK_DIR="/installation/trimesh2/lib.Linux64" \
-S . -B ./build


RUN PATH=$PATH:"$HOME"/cmake/bin
RUN cmake --build ./build --parallel $(nproc)

FROM nvidia/cuda:12.1.0-devel-ubuntu20.04

WORKDIR /app/

COPY --from=0 /installation/cuda_voxelizer/build/cuda_voxelizer ./
COPY --from=0 /installation/cuda_voxelizer/test_models/bunny.OBJ ./

RUN ./cuda_voxelizer -o binvox -thrust -f ./bunny.OBJ -s 256
#RUN ./cuda_voxelizer -o binvox -thrust -f ./bunny.OBJ -s 512
#RUN ./cuda_voxelizer -o binvox -thrust -f ./bunny.OBJ -s 1024
#RUN ./cuda_voxelizer -o binvox -thrust -f ./bunny.OBJ -s 2048

ENTRYPOINT ["/app/cuda_voxelizer"]
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ The project has the following build dependencies:
* [GLM](http://glm.g-truc.net/0.9.8/index.html) for vector math. Any recent version will do.
* [OpenMP](https://www.openmp.org/) for multi-threading.

### Docker Compose
1. Install [Docker](https://docs.docker.com/get-docker/) & [Docker Compose](https://docs.docker.com/compose/)
2. Install the [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker)

Then you can use the app like this:
```bash
docker compose run cuda_voxelizer cuda_voxelizer -o binvox -thrust -f ./test_models/bunny.OBJ -s 256

```
This should create a binvox file in the test_models folder.
If you have a cuda enabled gpu it will use it(maybe you have to lower the cuda arch variable in the Dockerfile).
You can always add more folders inside of the docker-compose.yml.

With this way, you dont have to install all the dependencies yourself.
In the following ways you have to do the steps described in the Dockerfile yourself.

### Build using CMake (Windows, Linux)

After installing dependencies, do `mkdir build` and `cd build`, followed by:
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3'
services:
cuda_voxelizer:
image: forceflow/cuda_voxelizer
build: .
volumes:
- ./test_models/:/app/test_models/