Commit
•
93ae114
1
Parent(s):
6dfbade
wip: Move to Fly app named medicode and attempt GPU
Browse files- Dockerfile +34 -0
- README.md +1 -1
- config/prod.exs +4 -0
- config/runtime.exs +2 -2
- fly.toml +10 -16
- lib/medicode/application.ex +1 -1
Dockerfile
CHANGED
@@ -26,6 +26,15 @@ RUN apt-get update -y && apt-get install -y build-essential git curl \
|
|
26 |
libportaudio2 libportaudiocpp0 \
|
27 |
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# prepare build dir
|
30 |
WORKDIR /app
|
31 |
|
@@ -36,6 +45,11 @@ RUN mix local.hex --force && \
|
|
36 |
# set build ENV
|
37 |
ENV MIX_ENV="prod"
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
# install mix dependencies
|
40 |
COPY mix.exs mix.lock ./
|
41 |
RUN mix deps.get --only $MIX_ENV
|
@@ -95,6 +109,14 @@ RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd
|
|
95 |
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb \
|
96 |
&& apt-get clean && rm -f ./google-chrome-stable_current_amd64.deb
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
# Set the locale
|
99 |
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
100 |
|
@@ -108,6 +130,18 @@ RUN chown nobody /app
|
|
108 |
# set runner ENV
|
109 |
ENV MIX_ENV="prod"
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
# Only copy the final release from the build stage
|
112 |
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/medicode ./
|
113 |
|
|
|
26 |
libportaudio2 libportaudiocpp0 \
|
27 |
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
|
28 |
|
29 |
+
# Add the repository for the Nvidia CUDA
|
30 |
+
# Import the Nvidia repository GPG key
|
31 |
+
RUN apt update -q && apt install -y ca-certificates wget && \
|
32 |
+
wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
|
33 |
+
dpkg -i /cuda-keyring.deb && apt update -q
|
34 |
+
|
35 |
+
# Install nvidia GPU support
|
36 |
+
RUN apt-get install -y cuda-nvcc-12-2 libcublas-12-2 libcudnn8
|
37 |
+
|
38 |
# prepare build dir
|
39 |
WORKDIR /app
|
40 |
|
|
|
45 |
# set build ENV
|
46 |
ENV MIX_ENV="prod"
|
47 |
|
48 |
+
# bumblebee - XLA_TARGET must exist before deps pulled
|
49 |
+
ENV XLA_TARGET="cuda120"
|
50 |
+
ENV BUMBLEBEE_CACHE_DIR="/data/cache/bumblebee"
|
51 |
+
ENV XLA_CACHE_DIR="/data/cache/xla"
|
52 |
+
|
53 |
# install mix dependencies
|
54 |
COPY mix.exs mix.lock ./
|
55 |
RUN mix deps.get --only $MIX_ENV
|
|
|
109 |
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb \
|
110 |
&& apt-get clean && rm -f ./google-chrome-stable_current_amd64.deb
|
111 |
|
112 |
+
# Nvidia stuff
|
113 |
+
RUN apt update -q && apt install -y ca-certificates wget && \
|
114 |
+
wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
|
115 |
+
dpkg -i /cuda-keyring.deb && apt update -q
|
116 |
+
|
117 |
+
# Nvidia support in runtime layer
|
118 |
+
RUN apt-get install -y --no-install-recommends cuda-nvcc-12-2 libcublas-12-2 libcudnn8
|
119 |
+
|
120 |
# Set the locale
|
121 |
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
122 |
|
|
|
130 |
# set runner ENV
|
131 |
ENV MIX_ENV="prod"
|
132 |
|
133 |
+
# Bumblebee
|
134 |
+
ENV XLA_TARGET="cuda120"
|
135 |
+
ENV BUMBLEBEE_CACHE_DIR="/data/cache/bumblebee"
|
136 |
+
ENV XLA_CACHE_DIR="/data/cache/xla"
|
137 |
+
|
138 |
+
# ENV CUDA_HOME="/usr/local/cuda"
|
139 |
+
# ENV PATH="${CUDA_HOME}/bin:${PATH}"
|
140 |
+
# ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:$LD_LIBRARY_PATH"
|
141 |
+
|
142 |
+
RUN echo "export PATH=/usr/local/cuda/bin:${PATH}" >> /root/.bashrc
|
143 |
+
RUN echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> /root/.bashrc
|
144 |
+
|
145 |
# Only copy the final release from the build stage
|
146 |
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/medicode ./
|
147 |
|
README.md
CHANGED
@@ -39,7 +39,7 @@ In addition to connecting to the deployed application via `iex`, Livebook suppor
|
|
39 |
2. Install and start Livebook: [Livebook.dev](https://livebook.dev/)
|
40 |
3. [Connecting Livebook to a Production App](https://fly.io/docs/elixir/advanced-guides/connect-livebook-to-your-app/) requires a node name and cookie value:
|
41 |
|
42 |
-
- Node name: `
|
43 |
- Cookie value: `0gfxcPtwryKxI2O1N0eFAg9p4MJGC-oUGShgj_wgvNEGiba5EDEJFA==` (this value is set in `fly.toml`)
|
44 |
|
45 |
## Run in Docker
|
|
|
39 |
2. Install and start Livebook: [Livebook.dev](https://livebook.dev/)
|
40 |
3. [Connecting Livebook to a Production App](https://fly.io/docs/elixir/advanced-guides/connect-livebook-to-your-app/) requires a node name and cookie value:
|
41 |
|
42 |
+
- Node name: `medicode@myipfromfly` ("myipfromfly" can be retrieved with `fly ips private --app medical-transcription-cpu`)
|
43 |
- Cookie value: `0gfxcPtwryKxI2O1N0eFAg9p4MJGC-oUGShgj_wgvNEGiba5EDEJFA==` (this value is set in `fly.toml`)
|
44 |
|
45 |
## Run in Docker
|
config/prod.exs
CHANGED
@@ -13,6 +13,10 @@ config :logger, level: :info
|
|
13 |
# NOTE: This path is the default from `apt-get install google-chrome-stable_current_amd64.deb` as found in Dockerfile
|
14 |
config :medicode, chrome_executable: "/usr/bin/google-chrome"
|
15 |
|
|
|
|
|
|
|
|
|
16 |
config :sentry,
|
17 |
dsn:
|
18 |
"https://93626ebe7f1cacb3db3d824f1ef9c770@o4506193464459264.ingest.us.sentry.io/4506876998123520",
|
|
|
13 |
# NOTE: This path is the default from `apt-get install google-chrome-stable_current_amd64.deb` as found in Dockerfile
|
14 |
config :medicode, chrome_executable: "/usr/bin/google-chrome"
|
15 |
|
16 |
+
# For prod, disable the in-place console progress bar. It breaks the IO
|
17 |
+
# output in production environments causing the server to crash.
|
18 |
+
config :bumblebee, progress_bar_enabled: false
|
19 |
+
|
20 |
config :sentry,
|
21 |
dsn:
|
22 |
"https://93626ebe7f1cacb3db3d824f1ef9c770@o4506193464459264.ingest.us.sentry.io/4506876998123520",
|
config/runtime.exs
CHANGED
@@ -50,7 +50,7 @@ if config_env() == :prod do
|
|
50 |
"""
|
51 |
|
52 |
host = System.get_env("PHX_HOST") || "example.com"
|
53 |
-
port = String.to_integer(System.
|
54 |
|
55 |
config :medicode, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
56 |
|
@@ -76,7 +76,7 @@ if config_env() == :prod do
|
|
76 |
config :flame, :backend, FLAME.FlyBackend
|
77 |
|
78 |
config :flame, FLAME.FlyBackend,
|
79 |
-
token: System.
|
80 |
gpu_kind: "a100-pcie-40gb",
|
81 |
cpu_kind: "performance",
|
82 |
cpus: 8,
|
|
|
50 |
"""
|
51 |
|
52 |
host = System.get_env("PHX_HOST") || "example.com"
|
53 |
+
port = String.to_integer(System.fetch_env!("PORT"))
|
54 |
|
55 |
config :medicode, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
56 |
|
|
|
76 |
config :flame, :backend, FLAME.FlyBackend
|
77 |
|
78 |
config :flame, FLAME.FlyBackend,
|
79 |
+
token: System.get_env("MEDICODE_API_TOKEN", "MEDICODE_API_TOKEN is currently not in use"),
|
80 |
gpu_kind: "a100-pcie-40gb",
|
81 |
cpu_kind: "performance",
|
82 |
cpus: 8,
|
fly.toml
CHANGED
@@ -1,17 +1,11 @@
|
|
1 |
-
# fly.toml app configuration file generated for
|
2 |
#
|
3 |
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
4 |
#
|
5 |
|
6 |
-
app =
|
7 |
-
primary_region =
|
8 |
-
kill_signal =
|
9 |
-
|
10 |
-
# TODO: Enable the following line and install the necessary CUDA packages in the Dockerfile for GPU usage.
|
11 |
-
# The volumes will need to be recreated as well to match the GPU kind.
|
12 |
-
# See https://fly.io/docs/gpus/gpu-quickstart/
|
13 |
-
# and https://fly.io/docs/gpus/getting-started-gpus/
|
14 |
-
# vm.size = "a100-40gb"
|
15 |
|
16 |
[build]
|
17 |
|
@@ -21,22 +15,22 @@ kill_signal = "SIGTERM"
|
|
21 |
[env]
|
22 |
AUDIO_TAGGER_CACHE_DIR = '/data/cache/audio_tagger'
|
23 |
BUMBLEBEE_CACHE_DIR = '/data/cache/bumblebee'
|
24 |
-
|
25 |
-
PHX_HOST = 'medical-transcription-cpu.fly.dev'
|
26 |
PORT = '8080'
|
27 |
RELEASE_COOKIE = '0gfxcPtwryKxI2O1N0eFAg9p4MJGC-oUGShgj_wgvNEGiba5EDEJFA=='
|
28 |
XLA_CACHE_DIR = '/data/cache/xla'
|
|
|
29 |
|
30 |
[[mounts]]
|
31 |
source = 'data'
|
32 |
destination = '/data'
|
33 |
-
initial_size = '
|
34 |
|
35 |
[http_service]
|
36 |
internal_port = 8080
|
37 |
force_https = true
|
38 |
auto_stop_machines = true
|
39 |
-
auto_start_machines =
|
40 |
min_machines_running = 0
|
41 |
processes = ['app']
|
42 |
|
@@ -46,6 +40,6 @@ kill_signal = "SIGTERM"
|
|
46 |
soft_limit = 1000
|
47 |
|
48 |
[[vm]]
|
49 |
-
memory = '
|
50 |
-
cpu_kind = '
|
51 |
cpus = 4
|
|
|
1 |
+
# fly.toml app configuration file generated for medicode on 2024-04-02T09:09:18-05:00
|
2 |
#
|
3 |
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
4 |
#
|
5 |
|
6 |
+
app = 'medicode'
|
7 |
+
primary_region = 'ord'
|
8 |
+
kill_signal = 'SIGTERM'
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
[build]
|
11 |
|
|
|
15 |
[env]
|
16 |
AUDIO_TAGGER_CACHE_DIR = '/data/cache/audio_tagger'
|
17 |
BUMBLEBEE_CACHE_DIR = '/data/cache/bumblebee'
|
18 |
+
PHX_HOST = 'medicode.fly.dev'
|
|
|
19 |
PORT = '8080'
|
20 |
RELEASE_COOKIE = '0gfxcPtwryKxI2O1N0eFAg9p4MJGC-oUGShgj_wgvNEGiba5EDEJFA=='
|
21 |
XLA_CACHE_DIR = '/data/cache/xla'
|
22 |
+
CUDA_HOME = '/usr/local/cuda'
|
23 |
|
24 |
[[mounts]]
|
25 |
source = 'data'
|
26 |
destination = '/data'
|
27 |
+
initial_size = '100gb'
|
28 |
|
29 |
[http_service]
|
30 |
internal_port = 8080
|
31 |
force_https = true
|
32 |
auto_stop_machines = true
|
33 |
+
auto_start_machines = false
|
34 |
min_machines_running = 0
|
35 |
processes = ['app']
|
36 |
|
|
|
40 |
soft_limit = 1000
|
41 |
|
42 |
[[vm]]
|
43 |
+
memory = '16gb'
|
44 |
+
cpu_kind = 'performance'
|
45 |
cpus = 4
|
lib/medicode/application.ex
CHANGED
@@ -17,7 +17,7 @@ defmodule Medicode.Application do
|
|
17 |
Medicode.Repo,
|
18 |
{DNSCluster, query: Application.get_env(:medicode, :dns_cluster_query) || :ignore},
|
19 |
{Phoenix.PubSub, name: :medicode_pubsub},
|
20 |
-
{FLAME.Pool, name: Medicode.OfflineServing, min: 0, max: 1},
|
21 |
Medicode.ServingSupervisor,
|
22 |
{
|
23 |
Medicode.TranscriptionSupervisor,
|
|
|
17 |
Medicode.Repo,
|
18 |
{DNSCluster, query: Application.get_env(:medicode, :dns_cluster_query) || :ignore},
|
19 |
{Phoenix.PubSub, name: :medicode_pubsub},
|
20 |
+
# {FLAME.Pool, name: Medicode.OfflineServing, min: 0, max: 1},
|
21 |
Medicode.ServingSupervisor,
|
22 |
{
|
23 |
Medicode.TranscriptionSupervisor,
|