Skip to content

Commit ec4396b

Browse files
authored
Merge pull request #1 from allen-munsch/cuda
add cuda support to mosaicdb
2 parents 4a7b9d7 + a6a0b3b commit ec4396b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3828
-737
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ config/prod.secret.exs
4545
/node_modules
4646
/assets/node_modules
4747
/assets/_build
48+
context/

Dockerfile

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
FROM elixir:1.16-alpine
2-
3-
# Install runtime dependencies
4-
RUN apk add --no-cache \
5-
build-base \
1+
# Use the specified Elixir image as base
2+
FROM elixir:1.19.3-otp-28-slim
3+
4+
# Install necessary system dependencies
5+
# build-essential for compilation tools, git for mix deps that might be from git,
6+
# sqlite3 for the SQLite client (useful for debugging inside the container)
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
69
git \
7-
sqlite \
10+
sqlite3 \
811
curl \
9-
bash
10-
11-
# Install hex and rebar
12-
RUN mix local.hex --force && \
13-
mix local.rebar --force
12+
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
13+
&& rm -rf /var/lib/apt/lists/*
14+
ENV PATH="/root/.cargo/bin:$PATH"
1415

15-
# Set working directory
16+
# Set the working directory inside the container
1617
WORKDIR /app
1718

18-
# Copy mix files
19-
COPY mix.exs mix.lock ./
20-
21-
# Install dependencies
22-
ENV MIX_ENV=dev
23-
RUN mix deps.get
24-
25-
# Copy application code
26-
COPY config ./config
27-
COPY lib ./lib
28-
COPY priv ./priv
19+
# Copy the application code
20+
COPY . /app
2921

30-
# Compile
31-
RUN mix compile
22+
# Install Elixir dependencies and compile the project
23+
# Use --force to ensure recompilation if needed
24+
# mix ecto.create and mix ecto.migrate are placeholders if you have Ecto setup
25+
RUN mix deps.get --only prod && \
26+
mix deps.compile sqlite_vec && \
27+
mix deps.compile duckdbex && \
28+
mix compile
3229

33-
# Expose port
30+
# Expose the port your application runs on
3431
EXPOSE 4040
3532

36-
# Run with mix (no release needed)
33+
# Define the command to run your application
3734
CMD ["mix", "run", "--no-halt"]

Dockerfile.cuda

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Use an official NVIDIA CUDA runtime image as base
2+
FROM docker.io/nvidia/cuda:12.3.2-devel-ubuntu22.04
3+
ENV LANG=C.UTF-8
4+
ENV LC_ALL=C.UTF-8
5+
6+
# Install common dependencies needed for Elixir/Erlang and build tools
7+
RUN apt-get update && \
8+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9+
build-essential \
10+
git \
11+
curl \
12+
libcudnn9-cuda-12 \
13+
libcudnn9-dev-cuda-12 \
14+
sqlite3 \
15+
libsqlite3-dev \
16+
ca-certificates \
17+
libssl-dev \
18+
libncurses5-dev \
19+
libwxgtk3.0-gtk3-dev \
20+
libgl1-mesa-dev \
21+
libglu1-mesa-dev \
22+
unzip \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Install asdf-vm
26+
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
27+
ENV PATH="/root/.asdf/bin:/root/.asdf/shims:$PATH"
28+
29+
# Install Erlang and Elixir plugins for asdf
30+
RUN asdf plugin add erlang || true
31+
RUN asdf plugin add elixir || true
32+
33+
# Set Erlang and Elixir versions
34+
ENV ERLANG_VERSION="28.2"
35+
ENV ELIXIR_VERSION="1.19.3"
36+
37+
RUN asdf install erlang ${ERLANG_VERSION}
38+
RUN asdf global erlang ${ERLANG_VERSION}
39+
RUN asdf install elixir ${ELIXIR_VERSION}
40+
RUN asdf global elixir ${ELIXIR_VERSION}
41+
42+
# Install Rust toolchain for Rustler NIFs
43+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
44+
&& export PATH="/root/.cargo/bin:$PATH" \
45+
&& echo "source $HOME/.cargo/env" >> ~/.bashrc
46+
ENV PATH="/root/.cargo/bin:$PATH"
47+
ENV XLA_TARGET=cuda12
48+
ENV PATH="/usr/local/cuda/bin:${PATH}"
49+
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda-12.3/targets/x86_64-linux/lib:${LD_LIBRARY_PATH}"
50+
ENV MIX_ENV=dev
51+
52+
WORKDIR /app
53+
COPY . /app
54+
55+
# Ensure start_app.sh is executable
56+
COPY start_app.sh /app/start_app.sh
57+
RUN chmod +x /app/start_app.sh
58+
59+
# Install Elixir dependencies and compile the project
60+
RUN mix deps.get && \
61+
mix deps.compile
62+
63+
# Expose the port your application runs on
64+
EXPOSE 4040
65+
66+
# Define the command to run your application
67+
CMD ["bash", "-c", "MIX_ENV=dev elixir --sname mosaic_app@mosaic --cookie supersecretcookie --erl '-pa /app/_build/dev/lib' -S mix run --no-halt"]

0 commit comments

Comments
 (0)