Skip to content

Commit 1127e4e

Browse files
authoredApr 28, 2020
Overhaul the project to make managing image versions easier (#26)
1 parent 537d896 commit 1127e4e

30 files changed

+675
-849
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.4.0-cuda10.1-ubuntu16.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.4.0-cuda10.1-ubuntu16.04/*
9+
- .github/workflows/publish_1.4.0-cuda10.1-ubuntu16.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.4.0-cuda10.1-ubuntu16.04,1.4.0-cuda10.1
22+
path: dockerfiles/1.4.0-cuda10.1-ubuntu16.04
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.4.0-cuda9.2-ubuntu16.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.4.0-cuda9.2-ubuntu16.04/*
9+
- .github/workflows/publish_1.4.0-cuda9.2-ubuntu16.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.4.0-cuda9.2-ubuntu16.04,1.4.0-cuda9.2
22+
path: dockerfiles/1.4.0-cuda9.2-ubuntu16.04
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.4.0-nocuda-ubuntu16.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.4.0-nocuda-ubuntu16.04/*
9+
- .github/workflows/publish_1.4.0-nocuda-ubuntu16.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.4.0-nocuda-ubuntu16.04,1.4.0-nocuda
22+
path: dockerfiles/1.4.0-nocuda-ubuntu16.04
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.5.0-cuda10.2-ubuntu18.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.5.0-cuda10.2-ubuntu18.04/*
9+
- .github/workflows/publish_1.5.0-cuda10.2-ubuntu18.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.5.0-cuda10.2-ubuntu18.04,1.5.0-cuda10.2,latest
22+
path: dockerfiles/1.5.0-cuda10.2-ubuntu18.04
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.5.0-cuda9.2-ubuntu18.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.5.0-cuda9.2-ubuntu18.04/*
9+
- .github/workflows/publish_1.5.0-cuda9.2-ubuntu18.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.5.0-cuda9.2-ubuntu18.04,1.5.0-cuda9.2
22+
path: dockerfiles/1.5.0-cuda9.2-ubuntu18.04
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish anibali/pytorch:1.5.0-nocuda-ubuntu18.04
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- dockerfiles/1.5.0-nocuda-ubuntu18.04/*
9+
- .github/workflows/publish_1.5.0-nocuda-ubuntu18.04.yml
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
repository: anibali/pytorch
21+
tags: 1.5.0-nocuda-ubuntu18.04,1.5.0-nocuda
22+
path: dockerfiles/1.5.0-nocuda-ubuntu18.04

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.swp
2+
.vscode

‎Dockerfile.template

-71
This file was deleted.

‎README.md

+12-37
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,22 @@ the image you intend to use_ via
2525
As an example, if you intend on using the `cuda-10.1` image then setting up
2626
CUDA 10.1 or CUDA 10.2 should ensure that you have the correct graphics drivers.
2727

28-
You will also need to install `nvidia-docker2` to enable GPU device access
29-
within Docker containers. This can be found at
28+
You will also need to install the NVIDIA Container Toolkit to enable GPU device
29+
access within Docker containers. This can be found at
3030
[NVIDIA/nvidia-docker](https://github.com/NVIDIA/nvidia-docker).
3131

3232

3333
### Prebuilt images
3434

3535
Prebuilt images are available on Docker Hub under the name
36-
[anibali/pytorch](https://hub.docker.com/r/anibali/pytorch/). For example,
37-
you can pull the CUDA 10.1 version with:
36+
[anibali/pytorch](https://hub.docker.com/r/anibali/pytorch/).
37+
38+
For example, you can pull an image with PyTorch 1.5.0 and CUDA 10.2 using:
3839

3940
```bash
40-
$ docker pull anibali/pytorch:cuda-10.1
41+
$ docker pull anibali/pytorch:1.5.0-cuda10.2
4142
```
4243

43-
The table below lists software versions for each of the currently supported
44-
Docker image tags available for `anibali/pytorch`.
45-
46-
| Image tag | CUDA | PyTorch |
47-
|-------------|-------|---------|
48-
| `no-cuda` | None | 1.4.0 |
49-
| `cuda-10.1` | 10.1 | 1.4.0 |
50-
| `cuda-9.2` | 9.2 | 1.4.0 |
51-
52-
The following images are also available, but are deprecated.
53-
54-
| Image tag | CUDA | PyTorch |
55-
|-------------|-------|---------|
56-
| `cuda-10.0` | 10.0 | 1.2.0 |
57-
| `cuda-9.1` | 9.1 | 0.4.0 |
58-
| `cuda-9.0` | 9.0 | 1.0.0 |
59-
| `cuda-8.0` | 8.0 | 1.0.0 |
60-
| `cuda-7.5` | 7.5 | 0.3.0 |
61-
6244

6345
### Usage
6446

@@ -71,33 +53,26 @@ the following command:
7153

7254
```sh
7355
docker run --rm -it --init \
74-
--runtime=nvidia \
56+
--gpus=all \
7557
--ipc=host \
7658
--user="$(id -u):$(id -g)" \
7759
--volume="$PWD:/app" \
78-
-e NVIDIA_VISIBLE_DEVICES=0 \
7960
anibali/pytorch python3 main.py
8061
```
8162

8263
Here's a description of the Docker command-line options shown above:
8364

84-
* `--runtime=nvidia`: Required if using CUDA, optional otherwise. Passes the
85-
graphics card from the host to the container.
65+
* `--gpus=all`: Required if using CUDA, optional otherwise. Passes the
66+
graphics cards from the host to the container. You can also more precisely
67+
control which graphics cards are exposed using this option (see documentation
68+
at https://github.com/NVIDIA/nvidia-docker).
8669
* `--ipc=host`: Required if using multiprocessing, as explained at
8770
https://github.com/pytorch/pytorch#docker-image.
8871
* `--user="$(id -u):$(id -g)"`: Sets the user inside the container to match your
8972
user and group ID. Optional, but is useful for writing files with correct
9073
ownership.
9174
* `--volume="$PWD:/app"`: Mounts the current working directory into the container.
9275
The default working directory inside the container is `/app`. Optional.
93-
* `-e NVIDIA_VISIBLE_DEVICES=0`: Sets an environment variable to restrict which
94-
graphics cards are seen by programs running inside the container. Set to `all`
95-
to enable all cards. Optional, defaults to all.
96-
97-
You may wish to consider using [Docker Compose](https://docs.docker.com/compose/)
98-
to make running containers with many options easier. At the time of writing,
99-
only version 2.3 of Docker Compose configuration files supports the `runtime`
100-
option.
10176

10277
#### Running graphical applications
10378

@@ -121,7 +96,7 @@ example:
12196

12297
```sh
12398
docker run --rm -it --init \
124-
--runtime=nvidia \
99+
--gpus=all \
125100
-e "DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
126101
anibali/pytorch python3 -c "import tkinter; tkinter.Tk().mainloop()"
127102
```

‎cuda-10.0/Dockerfile

-76
This file was deleted.

‎cuda-10.1/Dockerfile

-76
This file was deleted.

‎cuda-7.5/Dockerfile

-77
This file was deleted.

‎cuda-8.0/Dockerfile

-77
This file was deleted.

‎cuda-9.0/Dockerfile

-77
This file was deleted.

‎cuda-9.1/Dockerfile

-77
This file was deleted.

‎cuda-9.2/Dockerfile

-76
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM nvidia/cuda:10.1-base-ubuntu16.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.6
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.6.9 \
35+
&& conda clean -ya
36+
37+
# CUDA 10.1-specific steps
38+
RUN conda install -y -c pytorch \
39+
cudatoolkit=10.1 \
40+
"pytorch=1.4.0=py3.6_cuda10.1.243_cudnn7.6.3_0" \
41+
"torchvision=0.5.0=py36_cu101" \
42+
&& conda clean -ya
43+
44+
# Set the default command to python3
45+
CMD ["python3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM nvidia/cuda:9.2-base-ubuntu16.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.6
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.6.9 \
35+
&& conda clean -ya
36+
37+
# CUDA 9.2-specific steps
38+
RUN conda install -y -c pytorch \
39+
cudatoolkit=9.2 \
40+
"pytorch=1.4.0=py3.6_cuda9.2.148_cudnn7.6.3_0" \
41+
"torchvision=0.5.0=py36_cu92" \
42+
&& conda clean -ya
43+
44+
# Set the default command to python3
45+
CMD ["python3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM ubuntu:16.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.6
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.6.9 \
35+
&& conda clean -ya
36+
37+
# No CUDA-specific steps
38+
ENV NO_CUDA=1
39+
RUN conda install -y -c pytorch \
40+
cpuonly \
41+
"pytorch=1.4.0=py3.6_cpu_0" \
42+
"torchvision=0.5.0=py36_cpu" \
43+
&& conda clean -ya
44+
45+
# Set the default command to python3
46+
CMD ["python3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM nvidia/cuda:10.2-base-ubuntu18.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.8
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.8.1 \
35+
&& conda clean -ya
36+
37+
# CUDA 10.2-specific steps
38+
RUN conda install -y -c pytorch \
39+
cudatoolkit=10.2 \
40+
"pytorch=1.5.0=py3.8_cuda10.2.89_cudnn7.6.5_0" \
41+
"torchvision=0.6.0=py38_cu102" \
42+
&& conda clean -ya
43+
44+
# Set the default command to python3
45+
CMD ["python3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM nvidia/cuda:9.2-base-ubuntu18.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.8
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.8.1 \
35+
&& conda clean -ya
36+
37+
# CUDA 9.2-specific steps
38+
RUN conda install -y -c pytorch \
39+
cudatoolkit=9.2 \
40+
"pytorch=1.5.0=py3.8_cuda9.2.148_cudnn7.6.3_0" \
41+
"torchvision=0.6.0=py38_cu92" \
42+
&& conda clean -ya
43+
44+
# Set the default command to python3
45+
CMD ["python3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM ubuntu:18.04
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.8
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.8.1 \
35+
&& conda clean -ya
36+
37+
# No CUDA-specific steps
38+
ENV NO_CUDA=1
39+
RUN conda install -y -c pytorch \
40+
cpuonly \
41+
"pytorch=1.5.0=py3.8_cpu_0" \
42+
"torchvision=0.6.0=py38_cpu" \
43+
&& conda clean -ya
44+
45+
# Set the default command to python3
46+
CMD ["python3"]

‎environment.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: docker-pytorch
2+
channels:
3+
- defaults
4+
dependencies:
5+
- python=3.8.2
6+
- jinja2=2.11.1
7+
- pyyaml=5.3.1

‎images.yml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
1.5.0-cuda10.2-ubuntu18.04:
2+
extra_tags:
3+
- 1.5.0-cuda10.2
4+
- latest
5+
template:
6+
path: templates/ubuntu18.04.dockerfile.jinja2
7+
vars:
8+
base_image: nvidia/cuda:10.2-base-ubuntu18.04
9+
additional_steps: |-
10+
# CUDA 10.2-specific steps
11+
RUN conda install -y -c pytorch \
12+
cudatoolkit=10.2 \
13+
"pytorch=1.5.0=py3.8_cuda10.2.89_cudnn7.6.5_0" \
14+
"torchvision=0.6.0=py38_cu102" \
15+
&& conda clean -ya
16+
17+
1.5.0-cuda9.2-ubuntu18.04:
18+
extra_tags:
19+
- 1.5.0-cuda9.2
20+
template:
21+
path: templates/ubuntu18.04.dockerfile.jinja2
22+
vars:
23+
base_image: nvidia/cuda:9.2-base-ubuntu18.04
24+
additional_steps: |-
25+
# CUDA 9.2-specific steps
26+
RUN conda install -y -c pytorch \
27+
cudatoolkit=9.2 \
28+
"pytorch=1.5.0=py3.8_cuda9.2.148_cudnn7.6.3_0" \
29+
"torchvision=0.6.0=py38_cu92" \
30+
&& conda clean -ya
31+
32+
1.5.0-nocuda-ubuntu18.04:
33+
extra_tags:
34+
- 1.5.0-nocuda
35+
template:
36+
path: templates/ubuntu18.04.dockerfile.jinja2
37+
vars:
38+
base_image: ubuntu:18.04
39+
additional_steps: |-
40+
# No CUDA-specific steps
41+
ENV NO_CUDA=1
42+
RUN conda install -y -c pytorch \
43+
cpuonly \
44+
"pytorch=1.5.0=py3.8_cpu_0" \
45+
"torchvision=0.6.0=py38_cpu" \
46+
&& conda clean -ya
47+
48+
1.4.0-cuda10.1-ubuntu16.04:
49+
deprecated: true
50+
extra_tags:
51+
- 1.4.0-cuda10.1
52+
template:
53+
path: templates/ubuntu16.04.dockerfile.jinja2
54+
vars:
55+
base_image: nvidia/cuda:10.1-base-ubuntu16.04
56+
additional_steps: |-
57+
# CUDA 10.1-specific steps
58+
RUN conda install -y -c pytorch \
59+
cudatoolkit=10.1 \
60+
"pytorch=1.4.0=py3.6_cuda10.1.243_cudnn7.6.3_0" \
61+
"torchvision=0.5.0=py36_cu101" \
62+
&& conda clean -ya
63+
64+
1.4.0-cuda9.2-ubuntu16.04:
65+
deprecated: true
66+
extra_tags:
67+
- 1.4.0-cuda9.2
68+
template:
69+
path: templates/ubuntu16.04.dockerfile.jinja2
70+
vars:
71+
base_image: nvidia/cuda:9.2-base-ubuntu16.04
72+
additional_steps: |-
73+
# CUDA 9.2-specific steps
74+
RUN conda install -y -c pytorch \
75+
cudatoolkit=9.2 \
76+
"pytorch=1.4.0=py3.6_cuda9.2.148_cudnn7.6.3_0" \
77+
"torchvision=0.5.0=py36_cu92" \
78+
&& conda clean -ya
79+
80+
1.4.0-nocuda-ubuntu16.04:
81+
deprecated: true
82+
extra_tags:
83+
- 1.4.0-nocuda
84+
template:
85+
path: templates/ubuntu16.04.dockerfile.jinja2
86+
vars:
87+
base_image: ubuntu:16.04
88+
additional_steps: |-
89+
# No CUDA-specific steps
90+
ENV NO_CUDA=1
91+
RUN conda install -y -c pytorch \
92+
cpuonly \
93+
"pytorch=1.4.0=py3.6_cpu_0" \
94+
"torchvision=0.5.0=py36_cpu" \
95+
&& conda clean -ya

‎manager.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
3+
import jinja2
4+
import yaml
5+
from pathlib import Path
6+
7+
8+
DOCKER_REPOSITORY = 'anibali/pytorch'
9+
10+
11+
def main():
12+
# Directory for GitHub Actions workflow configuration files.
13+
workflow_dir = Path('.github', 'workflows')
14+
workflow_dir.mkdir(parents=True, exist_ok=True)
15+
16+
# Template file for Docker build and push workflows.
17+
workflow_template_path = Path('publish_workflow.yml.jinja2')
18+
workflow_template = jinja2.Template(workflow_template_path.read_text(encoding='utf-8'),
19+
keep_trailing_newline=True)
20+
21+
# Read Docker image configurations.
22+
images = yaml.safe_load(Path('images.yml').read_text(encoding='utf-8'))
23+
24+
for image_id, image_opts in images.items():
25+
if image_opts.get('deprecated', False):
26+
continue
27+
28+
tags = [image_id] + image_opts.get('extra_tags', [])
29+
template_path = Path(image_opts['template']['path'])
30+
template_vars = image_opts['template'].get('vars', {})
31+
32+
template = jinja2.Template(template_path.read_text(encoding='utf-8'),
33+
keep_trailing_newline=True)
34+
35+
dockerfile_dir = Path('dockerfiles', image_id)
36+
dockerfile_dir.mkdir(parents=True, exist_ok=True)
37+
38+
dockerfile_path = dockerfile_dir.joinpath('Dockerfile')
39+
dockerfile_content = template.render(**template_vars)
40+
dockerfile_path.write_text(dockerfile_content, encoding='utf-8')
41+
42+
workflow_path = workflow_dir.joinpath(f'publish_{image_id}.yml')
43+
workflow_content = workflow_template.render(
44+
image_id=image_id,
45+
repository=DOCKER_REPOSITORY,
46+
tags=tags,
47+
dockerfile_dir=str(dockerfile_dir),
48+
workflow_file=str(workflow_path),
49+
)
50+
workflow_path.write_text(workflow_content, encoding='utf-8')
51+
52+
53+
if __name__ == '__main__':
54+
main()

‎no-cuda/Dockerfile

-77
This file was deleted.

‎publish_workflow.yml.jinja2

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish {{ repository }}:{{ image_id }}
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- {{ dockerfile_dir }}/*
9+
- {{ workflow_file }}
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: docker/build-push-action@v1
17+
with:
18+
username: {% raw %}${{ secrets.DOCKER_USERNAME }}{% endraw %}
19+
password: {% raw %}${{ secrets.DOCKER_PASSWORD }}{% endraw %}
20+
repository: {{ repository }}
21+
tags: {{ tags | join(',') }}
22+
path: {{ dockerfile_dir }}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM {{ base_image }}
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.6
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.6.9 \
35+
&& conda clean -ya
36+
37+
{{ additional_steps }}
38+
39+
# Set the default command to python3
40+
CMD ["python3"]
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM {{ base_image }}
2+
3+
# Install some basic utilities
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
ca-certificates \
7+
sudo \
8+
git \
9+
bzip2 \
10+
libx11-6 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Create a working directory
14+
RUN mkdir /app
15+
WORKDIR /app
16+
17+
# Create a non-root user and switch to it
18+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
19+
&& chown -R user:user /app
20+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
21+
USER user
22+
23+
# All users can use /home/user as their home directory
24+
ENV HOME=/home/user
25+
RUN chmod 777 /home/user
26+
27+
# Install Miniconda and Python 3.8
28+
ENV CONDA_AUTO_UPDATE_CONDA=false
29+
ENV PATH=/home/user/miniconda/bin:$PATH
30+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh \
31+
&& chmod +x ~/miniconda.sh \
32+
&& ~/miniconda.sh -b -p ~/miniconda \
33+
&& rm ~/miniconda.sh \
34+
&& conda install -y python==3.8.1 \
35+
&& conda clean -ya
36+
37+
{{ additional_steps }}
38+
39+
# Set the default command to python3
40+
CMD ["python3"]

‎update.sh

-128
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.