-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
113 lines (97 loc) · 3.19 KB
/
Dockerfile
File metadata and controls
113 lines (97 loc) · 3.19 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
# use the official Python image from Docker Hub (slim in local, deepnote/python in deepnote)
#FROM python:3.8-slim
FROM deepnote/python:3.10
# install system dependencies
RUN apt-get update && apt-get install -y \
bash \
curl \
build-essential \
git \
cmake \
make \
gcc \
g++ \
ffmpeg \
libblas-dev \
liblapack-dev \
libopenblas-dev \
libcdd-dev \
python3-dev \
# for Rust
pkg-config \
libssl-dev \
clang \
llvm \
&& rm -rf /var/lib/apt/lists/*
# Install cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# make it more stable for acados build
ENV CARGO_BUILD_JOBS=2
ENV RUSTFLAGS="-C codegen-units=1"
# check
RUN cargo --version
# clone acados
RUN git clone https://github.com/acados/acados.git /acados && \
cd /acados && \
git submodule update --recursive --init
# build acados
RUN cd /acados && \
mkdir build && \
cd build && \
cmake .. -DACADOS_WITH_C_INTERFACE=ON -DACADOS_INSTALL_PYTHON=ON && \
make install
# double check acados_template
RUN cd /acados/interfaces/acados_template && \
pip install .
# ---- Patch to remove future_fstrings encoding header ----
RUN python - <<'PY'
import re, importlib.util, pathlib
pat = re.compile(r'^\s*#\s*-\*-\s*coding:\s*future_fstrings\s*-\*-\s*$', re.I)
def patch_tree(root: pathlib.Path):
if not root.exists(): return 0
n=0
for p in root.rglob("*.py"):
try:
L = p.read_text(encoding="utf-8", errors="ignore").splitlines(keepends=True)
except Exception: continue
ch=False
for i in (0,1):
if i < len(L) and pat.match(L[i]):
L[i] = "# -*- coding: utf-8 -*-\n"; ch=True
if ch:
p.write_text("".join(L), encoding="utf-8"); n+=1
print("patched", n, "files under", root)
spec = importlib.util.find_spec("acados_template")
if spec and spec.origin:
patch_tree(pathlib.Path(spec.origin).parent)
patch_tree(pathlib.Path("/acados"))
PY
# --------------------------------------------------
# Install t_renderer manually and replace the deafult one with wrong version
RUN git clone https://github.com/acados/tera_renderer.git /tera_renderer && \
cd /tera_renderer && \
cargo update -w && \
cargo build --release && \
mkdir -p /acados/bin && \
install -m 0755 /tera_renderer/target/release/t_renderer /acados/bin/t_renderer
# environment variables
ENV ACADOS_SOURCE_DIR=/acados
ENV ACADOS_INSTALL_DIR=/acados
ENV LD_LIBRARY_PATH=/acados/lib
ENV PYTHONPATH=/acados/interfaces/acados_template/python
# set the working directory
WORKDIR /app
# copy the current directory contents into the container at /app
COPY . /app
# install python dependencies
RUN python -m pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir seaborn cvxopt pycddlib==2.1.0 pytope
# install torch (cpu version)
RUN pip install --no-cache-dir torch==2.3.0+cpu torchvision \
--index-url https://download.pytorch.org/whl/cpu
# expose the port for jupyterlab
EXPOSE 8888
# entrypoint (bash in local, jupyter in Deepnote)
#CMD ["bash"]
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--no-browser", "--allow-root"]