-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
113 lines (94 loc) · 3.41 KB
/
Dockerfile
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
# Usage:
# docker build goma build-arg CUDA_VERSION=12.0.0
# 12.0.0 <- default configuration
# 11.7.0 <- you can also choose this
ARG CUDA_VERSION="12.2.0"
FROM nvidia/cuda:${CUDA_VERSION}-base-ubuntu22.04
ENV JULIA_PATH /usr/local/julia
ENV PATH $JULIA_PATH/bin:$PATH
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
ca-certificates \
curl \
git \
wget \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
htop \
nano \
openssh-server \
tig \
tree \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Julia
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.10/julia-1.10.4-linux-x86_64.tar.gz && \
mkdir "$JULIA_PATH" && \
tar zxvf julia-1.10.4-linux-x86_64.tar.gz -C "$JULIA_PATH" --strip-components 1 && \
rm julia-1.10.4-linux-x86_64.tar.gz # clean up
# Create user named jovyan which is compatible with Binder
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
WORKDIR /work/
RUN mkdir -p /work/
RUN chown -R ${NB_UID} /work/
USER ${NB_USER}
ENV PATH=$PATH:$HOME/.rye/shims
RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.32.0" RYE_INSTALL_OPTION="--yes" bash
RUN $HOME/.rye/shims/rye config --set-bool behavior.use-uv=true
RUN $HOME/.rye/shims/rye tools install jupyter \
&& $HOME/.rye/shims/rye tools install jupyterlab \
&& $HOME/.rye/shims/rye tools install jupytext \
&& $HOME/.rye/shims/rye tools install ruff
RUN mkdir -p ${HOME}/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension && \
echo '{"shortcuts": [{"command": "runmenu:restart-and-run-all", "keys": ["Alt R"], "selector": "[data-jp-code-runner]"}]}' >> \
${HOME}/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings
RUN jupytext-config set-default-viewer
# Install basic packages for default environment
RUN julia -e 'using Pkg; ENV["PYTHON"]=expanduser("~/.rye/shims/python3"); Pkg.add(["IJulia", "PyCall", "Pluto", "PlutoUI", "Revise", "BenchmarkTools"]); Pkg.precompile()'
# Install extra packages
RUN julia -e 'using Pkg; Pkg.add(["ImageFiltering"])'
ENV JULIA_PROJECT=/work
USER root
COPY Project.toml /work/
RUN mkdir -p /work/src && echo "module GomalizingFlow end" > /work/src/GomalizingFlow.jl
RUN chown -R ${NB_UID} /work/Project.toml
USER ${NB_USER}
RUN julia -e '\
using Pkg; Pkg.instantiate(); \
Pkg.precompile(); \
# Download CUDA artifacts \
using CUDA, cuDNN; \
env_cuda_version = ENV["CUDA_VERSION"]; \
using CUDA; CUDA.set_runtime_version!(VersionNumber(env_cuda_version)); \
'
RUN julia -e '\
using CUDA; \
if CUDA.functional() \
using cuDNN; \
@info "Downloading artifacts regarding CUDA and CUDNN for Julia"; \
@assert CUDA.functional(true); \
@assert cuDNN.has_cudnn(); \
CUDA.versioninfo(); \
end; \
using InteractiveUtils; versioninfo() \
'
RUN julia -e 'using Pkg; Pkg.instantiate()'
# For Jupyter Notebook
EXPOSE 8888
# For Http Server
EXPOSE 8000
# For Pluto Server
EXPOSE 9999
ENV JULIA_EDITOR="code"
ENV EDITOR="nano"
RUN julia --threads auto -e 'using Base.Threads, IJulia; installkernel("Julia", "--project=@.", env=Dict("JULIA_NUM_THREADS"=>"$(nthreads())"))'
CMD ["julia"]