Skip to content

Commit 30791eb

Browse files
authored
Merge pull request #1871 from codalab/podmanUpdates
Podman updates & More Competition container security
2 parents 607b2fd + f85eb5c commit 30791eb

14 files changed

Lines changed: 91 additions & 136 deletions
Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,34 @@
1-
FROM fedora:37
1+
FROM fedora:42
22

33
# Include deps
44
RUN dnf -y update && \
5-
# https://bugzilla.redhat.com/show_bug.cgi?id=1995337#c3
6-
rpm --setcaps shadow-utils 2>/dev/null && \
75
dnf -y install podman fuse-overlayfs python3.9 \
86
--exclude container-selinux && \
97
dnf clean all && \
108
rm -rf /var/cache /var/log/dnf* /var/log/yum.*
119

12-
# Setup user
13-
RUN useradd worker; \
14-
echo -e "worker:1:999\nworker:1001:64535" > /etc/subuid; \
15-
echo -e "worker:1:999\nworker:1001:64535" > /etc/subgid;
10+
# Copy the podman-connections file to allow for podman inside the container to connect to podman on the host, running containers alongside podman instead of inside
11+
COPY podman/podman-connections.json /root/.config/containers/podman-connections.json
1612

1713
# Copy over the podman container configuration
1814
COPY podman/containers.conf /etc/containers/containers.conf
19-
COPY podman/worker-containers.conf /home/worker/.config/containers/containers.conf
15+
COPY podman/worker-containers.conf /root/.config/containers/containers.conf
2016

2117
# Copy over the podman storage configuration
22-
COPY podman/worker-storage.conf /home/worker/.config/containers/storage.conf
18+
COPY podman/worker-storage.conf /root/.config/containers/storage.conf
2319

24-
RUN mkdir -p /home/worker/.local/share/containers && \
25-
chown worker:worker -R /home/worker && \
26-
chmod 644 /etc/containers/containers.conf
20+
RUN mkdir -p /root/.local/share/containers
2721

2822
# Copy & modify the defaults to provide reference if runtime changes needed.
2923
# Changes here are required for running with fuse-overlay storage inside container.
3024
RUN sed -e 's|^#mount_program|mount_program|g' \
31-
-e '/additionalimage.*/a "/var/lib/shared",' \
32-
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
33-
/usr/share/containers/storage.conf \
34-
> /etc/containers/storage.conf
25+
-e '/additionalimage.*/a "/var/lib/shared",' \
26+
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
27+
/usr/share/containers/storage.conf \
28+
> /etc/containers/storage.conf
3529

3630
# Add volume for containers
37-
VOLUME /home/worker/.local/share/containers
38-
39-
# Create directory for tmp space
40-
RUN mkdir /codabench && \
41-
chown worker:worker /codabench
31+
VOLUME /root/.local/share/containers
4232

4333
# Set up podman registry for dockerhub
4434
RUN echo -e "[registries.search]\nregistries = ['docker.io']\n" > /etc/containers/registries.conf
@@ -47,18 +37,18 @@ RUN echo -e "[registries.search]\nregistries = ['docker.io']\n" > /etc/container
4737
ENV PYTHONUNBUFFERED 1
4838
ENV CONTAINER_ENGINE_EXECUTABLE podman
4939

50-
WORKDIR /home/worker/compute_worker
51-
52-
ADD compute_worker/ /home/worker/compute_worker
40+
WORKDIR /root/compute_worker
5341

54-
RUN chown worker:worker -R /home/worker/compute_worker
42+
ADD compute_worker/ /root/compute_worker
5543

56-
RUN curl -sSL https://install.python-poetry.org | python3.9 -
44+
RUN curl -sSL https://install.python-poetry.org | python3.9 - --version 1.8.3
5745
# Poetry location so future commands (below) work
5846
ENV PATH $PATH:/root/.local/bin
47+
5948
# Want poetry to use system python of docker container
6049
RUN poetry config virtualenvs.create false
6150
RUN poetry config virtualenvs.in-project false
51+
6252
# So we get 3.9
6353
RUN poetry config virtualenvs.prefer-active-python true
6454
COPY ./compute_worker/pyproject.toml ./
@@ -69,4 +59,4 @@ CMD celery -A compute_worker worker \
6959
-l info \
7060
-Q compute-worker \
7161
-n compute-worker@%n \
72-
--concurrency=1
62+
--concurrency=1
Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,8 @@
1-
FROM fedora:37
1+
FROM codalab/codabench_worker_podman:latest
22

33
# Include deps
4-
RUN curl -s -L https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo | tee /etc/yum.repos.d/cuda.repo && \
5-
curl -s -L https://nvidia.github.io/nvidia-docker/rhel9.0/nvidia-docker.repo | tee /etc/yum.repos.d/nvidia-docker.repo && \
6-
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm && \
7-
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && \
4+
RUN dnf -y config-manager addrepo --from-repofile=https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo && \
85
dnf -y update && \
9-
dnf module install -y nvidia-driver:latest-dkms && \
10-
dnf -y install podman fuse-overlayfs python3.9 nvidia-container-runtime nvidia-container-toolkit \
11-
cuda --exclude container-selinux && \
6+
dnf -y install nvidia-container-runtime nvidia-container-toolkit --exclude container-selinux && \
127
dnf clean all && \
13-
rm -rf /var/cache /var/log/dnf* /var/log/yum.*
14-
15-
# Setup user
16-
RUN useradd worker; \
17-
echo -e "worker:1:999\nworker:1001:64535" > /etc/subuid; \
18-
echo -e "worker:1:999\nworker:1001:64535" > /etc/subgid;
19-
20-
# Copy over the podman container configuration
21-
COPY podman/containers.conf /etc/containers/containers.conf
22-
COPY podman/worker-containers.conf /home/worker/.config/containers/containers.conf
23-
24-
# Copy over the podman storage configuration
25-
COPY podman/worker-storage.conf /home/worker/.config/containers/storage.conf
26-
27-
RUN mkdir -p /home/worker/.local/share/containers && \
28-
chown worker:worker -R /home/worker && \
29-
chmod 644 /etc/containers/containers.conf
30-
31-
# Copy & modify the defaults to provide reference if runtime changes needed.
32-
# Changes here are required for running with fuse-overlay storage inside container.
33-
RUN sed -e 's|^#mount_program|mount_program|g' \
34-
-e '/additionalimage.*/a "/var/lib/shared",' \
35-
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
36-
/usr/share/containers/storage.conf \
37-
> /etc/containers/storage.conf; sed -i 's/^#no-cgroups = false/no-cgroups = true/;' /etc/nvidia-container-runtime/config.toml
38-
39-
40-
# Add volume for containers
41-
VOLUME /home/worker/.local/share/containers
42-
43-
# This makes output not buffer and return immediately, nice for seeing results in stdout
44-
ENV PYTHONUNBUFFERED 1
45-
ENV CONTAINER_ENGINE_EXECUTABLE podman
46-
47-
# Create directory for tmp space
48-
RUN mkdir /codabench && \
49-
chown worker:worker /codabench && \
50-
# Set up podman registry for dockerhub
51-
echo -e "[registries.search]\nregistries = ['docker.io']\n" > /etc/containers/registries.conf && \
52-
53-
WORKDIR /home/worker/compute_worker
54-
55-
ADD compute_worker/ /home/worker/compute_worker
56-
57-
RUN curl -sSL https://install.python-poetry.org | python3.9 -
58-
# Poetry location so future commands (below) work
59-
ENV PATH $PATH:/root/.local/bin
60-
# Want poetry to use system python of docker container
61-
RUN poetry config virtualenvs.create false
62-
RUN poetry config virtualenvs.in-project false
63-
# So we get 3.9
64-
RUN poetry config virtualenvs.prefer-active-python true
65-
COPY ./compute_worker/pyproject.toml ./
66-
COPY ./compute_worker/poetry.lock ./
67-
RUN poetry install
68-
69-
RUN chown worker:worker -R /home/worker/compute_worker
70-
71-
CMD nvidia-smi && celery -A compute_worker worker \
72-
-l info \
73-
-Q compute-worker \
74-
-n compute-worker@%n \
75-
--concurrency=1
8+
rm -rf /var/cache /var/log/dnf* /var/log/yum.*

compute_worker/compute_worker.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,6 @@ async def _run_program_directory(self, program_dir, kind):
622622
logger.info(
623623
"Program directory missing metadata, assuming it's going to be handled by ingestion"
624624
)
625-
# Copy submission files into prediction output
626-
# This is useful for results submissions but wrongly uses storage
627-
shutil.copytree(program_dir, self.output_dir)
628625
return
629626
else:
630627
raise SubmissionException("Program directory missing 'metadata.yaml/metadata'")
@@ -660,21 +657,28 @@ async def _run_program_directory(self, program_dir, kind):
660657
# Don't allow subprocesses to raise privileges
661658
'--security-opt=no-new-privileges',
662659

663-
# Set the volumes
664-
'-v', f'{self._get_host_path(program_dir)}:/app/program',
665-
'-v', f'{self._get_host_path(self.output_dir)}:/app/output',
660+
# Set the volumes: ro for Read Only, z to allow multiple containers to access the volume (useful for podman)
661+
'-v', f'{self._get_host_path(program_dir)}:/app/program:z',
662+
'-v', f'{self._get_host_path(self.output_dir)}:/app/output:z',
666663
'-v', f'{self.data_dir}:/app/data:ro',
667664

668665
# Start in the right directory
669666
'-w', '/app/program',
670-
667+
668+
# Set the user namespace mode for the container
669+
'--userns', 'host',
670+
# Drop all capabilities
671+
'--cap-drop', 'all',
671672
# Don't buffer python output, so we don't lose any
672673
'-e', 'PYTHONUNBUFFERED=1',
673674
]
674675

675676
# GPU or not
676-
if os.environ.get("USE_GPU"):
677+
if os.environ.get("USE_GPU") and CONTAINER_ENGINE_EXECUTABLE=='docker':
677678
engine_cmd.extend(['--gpus', 'all'])
679+
# For podman specifically
680+
if os.environ.get("USE_GPU") and CONTAINER_ENGINE_EXECUTABLE=='podman':
681+
engine_cmd.extend(['--device', 'nvidia.com/gpu=all'])
678682

679683
if kind == 'ingestion':
680684
# program here is either scoring program or submission, depends on if this ran during Prediction or Scoring

documentation/docs/Newsletters_Archive/CodaLab-in-2024.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Contributors community is very active with **143 pull requests** this year. Sinc
1919
## Introducing Codabench
2020
[Codabench](https://codabench.org/), the modernized version of [CodaLab](https://codalab.lisn.fr/), was released in summer 2023, and [presented at JCAD days](https://www.canal-u.tv/chaines/jcad/codalab-competitions-and-codabench-open-source-platforms-to-organize-scientific) in November 2024! Codabench platform software is now concentrating all development effort of the community. In addition to CodaLab features, it offers improved performance, live logs, more transparency, data-centric benchmarks and more!
2121

22-
We warmly encourage you to use [codabench.org](https://codabench.org/) for all your new competitions and benchmarks. Note that CodaLab bundles are compatible with Codabench, easing the transition, as explained in the following Wiki page: [How-to-transition-from-CodaLab-to-Codabench](https://github.com/codalab/codabench/wiki/How-to-transition-from-CodaLab-to-Codabench%3F)
22+
We warmly encourage you to use [codabench.org](https://codabench.org/) for all your new competitions and benchmarks. Note that CodaLab bundles are compatible with Codabench, easing the transition, as explained in the following Wiki page: [How to transition from CodaLab to Codabench](../Organizers/Benchmark_Creation/How-to-transition-from-CodaLab-to-Codabench.md)
2323

2424
CodaLab and Codabench are hosted on servers located at [Paris-Saclay university](https://www.universite-paris-saclay.fr/), maintained by [LISN lab](http://lisn.upsaclay.fr/).
2525

documentation/docs/Organizers/Benchmark_Creation/Advanced-Tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Here is an advanced tutorial. If you are new to CodaBench, please refer to [get started tutorial](https://github.com/codalab/codabench/wiki/Getting-started-with-Codabench) first.
2+
Here is an advanced tutorial. If you are new to CodaBench, please refer to [get started tutorial](Getting-started-with-Codabench.md) first.
33
In this article, you'll learn how to use more advanced features and how to create benchmarks using either the editor or bundles.
44
Before proceeding to our tutorial, make sure you have registered for an account on the [Codabench](https://www.codabench.org/) website.
55

documentation/docs/Organizers/Benchmark_Creation/Competition-Bundle-Structure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ The scoring program outputs a `scores.json` file containing the results for each
108108
{"accuracy": 0.886, "duration": 42.4}
109109
```
110110

111-
The keys should match the leaderboard columns keys defined in [the `competition.yaml` file](https://github.com/codalab/codabench/wiki/Yaml-Structure#leaderboards).
111+
The keys should match the leaderboard columns keys defined in [the `competition.yaml` file](Yaml-Structure.md#leaderboards).
112112

113-
The scoring program can also output detailed results as an HTML file for each submission. [Click here for more information](https://github.com/codalab/codabench/wiki/Detailed-Results-and-Visualizations).
113+
The scoring program can also output detailed results as an HTML file for each submission. [Click here for more information](Detailed-Results-and-Visualizations.md).
114114

115115
### Ingestion Program
116116
The ingestion program is a file that gets ran to generate the predictions from the submissions if necessary. This is usually a python script or a script in another language, but it can generally be anything.
@@ -122,7 +122,7 @@ Example: Here's what an ingestion `metdata.yaml` might look like this:
122122
command: python3 /app/program/ingestion.py /app/input_data/ /app/output/ /app/program /app/ingested_program
123123
```
124124

125-
Just like the example above, this specifies we're using python to run our ingestion program. Please note that it is not necessary to pass these directories as arguments to the programs, but it can be convenient. More information about the folder layout [here](https://github.com/codalab/codabench/wiki/Submission-Docker-Container-Layout#submission-container).
125+
Just like the example above, this specifies we're using python to run our ingestion program. Please note that it is not necessary to pass these directories as arguments to the programs, but it can be convenient. More information about the folder layout [here](../../Developers_and_Administrators/Submission-Docker-Container-Layout.md#submission-container).
126126

127127
### Input Data
128128
This is usually the test data used to generate predictions from a user's code submission when paired with an ingestion program.

documentation/docs/Organizers/Benchmark_Creation/Competition-Creation:-Form.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ By clicking `Add phase`, you should be presented with a modal for phase creation
4343
- Name: The name of your phase
4444
- Start: The start day of your phase
4545
- End: The end day of your phase
46-
- Tasks: Here you can assign one or multiple task objects to your phase. Tasks are problems that the submission should be solving. For more information, see the explanation on competition structure [here](https://github.com/codalab/codabench/wiki/Competition-Bundle-Structure#what-is-a-competition): If you don't have any tasks created yet, click the green button at the bottom of the new phase modal titled `Manage Tasks/Datasets`
46+
- Tasks: Here you can assign one or multiple task objects to your phase. Tasks are problems that the submission should be solving. For more information, see the explanation on competition structure [here](Competition-Bundle-Structure.md#what-is-a-competition): If you don't have any tasks created yet, click the green button at the bottom of the new phase modal titled `Manage Tasks/Datasets`
4747
- Description: The description of your phase
4848

4949
*Advanced*

documentation/docs/Organizers/Benchmark_Creation/How-to-transition-from-CodaLab-to-Codabench?.md renamed to documentation/docs/Organizers/Benchmark_Creation/How-to-transition-from-CodaLab-to-Codabench.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
- Live logs during submission processes
1010
- Storage quotas
11-
- [Computation servers management](https://github.com/codalab/codabench/wiki/Server-status-page) for all users.
11+
- [Computation servers management](../Running_a_benchmark/Server-status-page.md) for all users.
1212

1313
It also emphasizes on benchmarking, allowing dataset submissions and multiple leaderboard rows per user. Finally, future project development and maintenance will be focused on Codabench.
1414

@@ -56,5 +56,5 @@ If you don’t have any previous competition, and want to learn how to create on
5656

5757
## Concluding remarks
5858

59-
Codabench, the new version of the competition and benchmark platform CodaLab, was launched on August 2023 and is already receiving great attention. For users accustomed to CodaLab, the transition to Codabench is quick and easy. Indeed, competition bundles are back-compatible, and all that is required is to create an account on Codabench. To go further, you can refer to [Codabench’s Wiki](https://github.com/codalab/codabench/wiki/).
59+
Codabench, the new version of the competition and benchmark platform CodaLab, was launched on August 2023 and is already receiving great attention. For users accustomed to CodaLab, the transition to Codabench is quick and easy. Indeed, competition bundles are back-compatible, and all that is required is to create an account on Codabench. To go further, you can refer to [Codabench’s Wiki](https://wiki.codabench.org).
6060

documentation/docs/Organizers/Running_a_benchmark/Compute-worker-installation-with-Podman.md

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Here is the specification for compute worker installation by using Podman.
2-
## Requirements for host machine
2+
## Requirements for the host machine
33

44
We need to install Podman on the VM. We use Debian based OS, like Ubuntu. Ubuntu is recommended, because it has better Nvidia driver support.
55

66
`sudo apt install podman `
77

8+
After installing Podman, you will need to launch the service associated to it with `systemctl --user enable --now podman`
9+
810
Then, configure where Podman will download the images: Podman will use Dockerhub by adding this line into `/etc/containers/registries.conf `:
911

1012
`unqualified-search-registries = ["docker.io"] `
@@ -19,12 +21,13 @@ BROKER_USE_SSL=True
1921
CONTAINER_ENGINE_EXECUTABLE=podman
2022
```
2123

22-
**Create user for running Podman container**
23-
```bash
24-
useradd worker
25-
```
24+
You will also need to create the `codabench` folder defined in the `.env` file, as well as change its permissions to the user that is running the compute worker.
2625

27-
!!! note "In order to use podman later to launch the computer worker, you need to have logged out completely first from whatever user you were using and log in as "worker". If you fail to do so, your environment will likely store environment variables tied to the original user and launching podman will not work."
26+
```bash title="In your terminal"
27+
sudo mkdir /codabench
28+
sudo mkdir /codabench/data
29+
sudo chown -R $(id -u):$(id -g) /codabench
30+
```
2831

2932
## For GPU compute worker VM
3033

@@ -103,6 +106,10 @@ podman run --rm -it \
103106
```
104107
The result should show as same as the command `nvidia-smi` above.
105108

109+
You will also need to add this line in your `.env` file:
110+
```bash
111+
USE_GPU=True
112+
```
106113

107114
## Compute worker installation
108115

@@ -112,14 +119,17 @@ Run the compute worker container :
112119

113120
```bash
114121
podman run -d \
115-
--env-file .env \
116-
--name compute_worker \
117-
--security-opt="label=disable" \
118-
--device /dev/fuse --user worker \
119-
--restart unless-stopped \
120-
--log-opt max-size=50m \
121-
--log-opt max-file=3 \
122-
codalab/codabench_worker_podman:0.1
122+
--volume /run/user/$(id -u)/podman/podman.sock:/run/user/1000/podman/podman.sock:U \
123+
--env-file .env \
124+
--name compute_worker \
125+
--security-opt="label=disable" \
126+
--userns host \
127+
--restart unless-stopped \
128+
--log-opt max-size=50m \
129+
--log-opt max-file=3 \
130+
--cap-drop all \
131+
--volume /codabench:/codabench:U,z \
132+
codalab/codabench_worker_podman:latest
123133
```
124134

125135
### For GPU container
@@ -129,12 +139,17 @@ Run the GPU compute worker container
129139
```bash
130140
podman run -d \
131141
--env-file .env \
132-
--privileged \
142+
--device nvidia.com/gpu=all \
133143
--name gpu_compute_worker \
134-
--device /dev/fuse --user worker \
144+
--device /dev/fuse \
135145
--security-opt="label=disable" \
136146
--restart unless-stopped \
137147
--log-opt max-size=50m \
138148
--log-opt max-file=3 \
139-
codalab/codabench_worker_podman_gpu:0.2
140-
```
149+
--hostname ${HOSTNAME} \
150+
--userns host \
151+
--volume /home/codalab/worker/codabench:/codabench:z,U \
152+
--cap-drop=all \
153+
--volume /run/user/$(id -u)/podman/podman.sock:/run/user/1000/podman/podman.sock:U \
154+
codalab/codabench_worker_podman_gpu:latest
155+
```

documentation/docs/Participants/User_Participating-in-a-Competition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Making a submission to a benchmark involves uploading a bundle (.zip archive) co
2222

2323
On this page, you can make new submissions, and see previous submissions for each phase in the competition.
2424

25-
You can also view all your submissions in the [Resources Interface](https://github.com/codalab/codabench/wiki/Task-&-Dataset-Management).
25+
You can also view all your submissions in the [Resources Interface](../Organizers/Running_a_benchmark/Resource-Management.md).
2626

2727
### Viewing Benchmark Results
2828
You can keep up with the progress of benchmarks you are participating in by clicking on the **Results** tab. This will display the leaderboard.

0 commit comments

Comments
 (0)