-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile_cpu
More file actions
160 lines (128 loc) · 5.56 KB
/
Dockerfile_cpu
File metadata and controls
160 lines (128 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
FROM ubuntu:24.04 AS builder
WORKDIR /workspace
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_VERSION=3.13.12
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
g++ \
gnupg \
libatomic1 \
libegl1 \
libbz2-dev \
libffi-dev \
libgl1 \
libgomp1 \
liblzma-dev \
libreadline-dev \
libsqlite3-dev \
lsb-release \
libssl-dev \
libx11-xcb1 \
make \
software-properties-common \
sqlite3 \
tzdata \
unzip \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
######################## Python installation #########################
# Download Python source code from official site and build it
RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz && \
tar -zxvf Python-$PYTHON_VERSION.tgz && \
cd Python-$PYTHON_VERSION && \
./configure --enable-optimizations && make && make install && \
cd .. && \
rm Python-$PYTHON_VERSION.tgz && \
rm -r Python-$PYTHON_VERSION
RUN wget https://bootstrap.pypa.io/get-pip.py -O get-pip.py
#################### Create Virtual Environment ######################
ENV VIRTUAL_ENV=/workspace/venv
RUN python3.13 -m venv $VIRTUAL_ENV
# by adding the venv to the search path, we avoid activating it in each command
# see https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# install pip into venv
RUN python get-pip.py && python -m pip install --upgrade pip
######## Install PyTorch and packages that depend on PyTorch #########
# these packages are dependencies of the other packages but not listed in their requirements
# therefore, they have to be installed manually
RUN python -m pip install tensorboard yapf wheel packaging
RUN python -m pip install torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cpu
RUN python -m pip install torch-scatter torch-cluster -f https://data.pyg.org/whl/torch-2.10.0+cpu.html
RUN python -m pip install --no-build-isolation "git+https://github.com/facebookresearch/pytorch3d.git@stable"
RUN python -m pip install spconv
######################## Open3D build #################################
RUN git clone https://github.com/isl-org/Open3D
RUN git clone https://github.com/isl-org/Open3D-ML.git
# remove sudo from script since it is not available in Docker
RUN sed -i 's/SUDO=${SUDO:=sudo}/SUDO=" "/g' Open3D/util/install_deps_ubuntu.sh && \
Open3D/util/install_deps_ubuntu.sh assume-yes
# install latest version of cmake
# see https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
RUN apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
RUN apt update && apt install kitware-archive-keyring && rm /etc/apt/trusted.gpg.d/kitware.gpg && apt install cmake -y
# build the Open3D package (CPU version)
RUN mkdir /workspace/Open3D/build && cd /workspace/Open3D/build && \
cmake -DPYTHON3_INCLUDE_DIR=$(python -c "import sysconfig && print(sysconfig.get_path('include'))") \
-DPYTHON3_LIBRARY=$(python -c "import sysconfig && print(sysconfig.get_config_var('LIBDIR'))") \
-DBUILD_CUDA_MODULE=OFF -DGLIBCXX_USE_CXX11_ABI=ON -DBUILD_PYTORCH_OPS=ON -DBUILD_TENSORFLOW_OPS=OFF \
-DBUNDLE_OPEN3D_ML=ON -DOPEN3D_ML_ROOT=/workspace/Open3D-ML .. && \
make -j$(nproc) && \
make install-pip-package
# uninstall build dependencies from virtual environment again
RUN python -m pip uninstall -y yapf wheel packaging
####################################################################
######################### Target Image #############################
####################################################################
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_VERSION=3.13.12
WORKDIR /workspace
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
g++ \
gnupg \
libatomic1 \
libegl1 \
libbz2-dev \
libffi-dev \
libgl1 \
libgomp1 \
liblzma-dev \
libreadline-dev \
libsqlite3-dev \
lsb-release \
libssl-dev \
libx11-xcb1 \
make \
software-properties-common \
sqlite3 \
tzdata \
unzip \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
######################## Rclone installation ########################
RUN curl https://rclone.org/install.sh | bash
#################### Copy Virtual Environment ######################
ENV VIRTUAL_ENV=/workspace/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=builder /workspace/venv /workspace/venv
# copy additional libs that are needed by Open3D
COPY --from=builder /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGL.so
COPY --from=builder /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so.1
COPY --from=builder /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0
COPY --from=builder /usr/lib/x86_64-linux-gnu/libGLX.so.0 /usr/lib/x86_64-linux-gnu/libGLX.so.0
# copy Python installation to avoid building Python twice
COPY --from=builder /usr/local/bin/python3.13 /usr/local/bin/python3.13
COPY --from=builder /usr/local/lib/python3.13 /usr/local/lib/python3.13
COPY --from=builder /usr/local/include/python3.13 /usr/local/include/python3.13
RUN mkdir pointtorch
ADD . pointtorch
RUN python -m pip install ./pointtorch[dev,docs]