Skip to content

Commit

Permalink
Merge branch 'tmp_fix_gh_pages' into 'master'
Browse files Browse the repository at this point in the history
[fix] create docker images for cpu

See merge request ricos/machine_learning/siml!276
  • Loading branch information
yellowshippo committed Sep 19, 2023
2 parents 0fb1736 + 3d3fcb0 commit 6ad02ac
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
docs:
runs-on: ubuntu-latest
container:
image: ghcr.io/ricosjp/siml:0.2.8
image: ghcr.io/ricosjp/siml/cpu:0.2.9
steps:
- uses: actions/checkout@v1
- name: sphinx
Expand Down
18 changes: 13 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
image: registry.ritc.jp/ricos/machine_learning/siml:0.2.9
variables:
IMAGE_VERSION: 0.2.9
SIML_IMAGE: registry.ritc.jp/ricos/machine_learning/siml:$IMAGE_VERSION
CPU_IMAGE: registry.ritc.jp/ricos/machine_learning/siml/cpu:$IMAGE_VERSION


image: $SIML_IMAGE

default:
before_script:
Expand Down Expand Up @@ -128,6 +134,7 @@ test_group:

pages:
stage: deploy
image: $CPU_IMAGE
script:
- poetry build
- python3.9 -m pip install dist/pysiml-*.whl
Expand All @@ -143,10 +150,11 @@ pages:
tags:
- avx
only:
- master
- develop
- fix_sphinx

refs:
- master
- develop
- fix_sphinx
- /^*_pages$/

.deploy:wheel:
stage: deploy
Expand Down
22 changes: 10 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ RUN apt-get update -y \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh 10 \
&& ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
&& ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config \
&& rm -rf /var/lib/apt/lists/*

ENV LLVM_CONFIG /usr/bin/llvm-config-10

Expand All @@ -43,26 +44,23 @@ ENV PYTHONPATH "$PYTHONPATH:/usr/lib/python3.9/site-packages"

# poerty
ENV PATH "$PATH:/root/.local/bin"
RUN curl -sSL https://install.python-poetry.org | python3.9 -

# Default version of python3 is python3.8.
# When virtual environment is not created by poetry,
# poetry use default version of python.
# In order to change default python version to python3.9,
# create symbolic link of python3.9
RUN unlink /usr/bin/python3
RUN ln -s /usr/bin/python3.9 /usr/bin/python3

RUN python3.9 -m pip install -U pip \
RUN curl -sSL https://install.python-poetry.org | python3.9 - \
&& unlink /usr/bin/python3 \
&& ln -s /usr/bin/python3.9 /usr/bin/python3 \
&& python3.9 -m pip install -U pip \
&& python3.9 -m pip install -U setuptools \
&& python3.9 -m pip install -U wheel \
&& python3.9 -m pip install --ignore-installed -U PyYAML \
&& python3.9 -m pip install Cython

RUN poetry config virtualenvs.create false \
&& poetry install

RUN poetry run python3 -m pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 -f https://download.pytorch.org/whl/torch_stable.html \
&& python3.9 -m pip install Cython \
&& poetry config virtualenvs.create false \
&& poetry install \
&& poetry run python3 -m pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 -f https://download.pytorch.org/whl/torch_stable.html \
&& poetry run python3 -m pip install torch-scatter==2.0.9 -f https://pytorch-geometric.com/whl/torch-1.10.1+cu111.html \
&& poetry run python3 -m pip install torch-sparse==0.6.13 -f https://pytorch-geometric.com/whl/torch-1.10.1+cu111.html \
&& poetry run python3 -m pip install torch-cluster==1.6.0 -f https://pytorch-geometric.com/whl/torch-1.10.1+cu111.html \
Expand Down
69 changes: 69 additions & 0 deletions docker/Dockerfile_cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
git \
make \
gcc \
ssh \
curl \
libglu1-mesa-dev \
libxrender1 \
g++ \
lsb-release wget software-properties-common \
libedit-dev \
libmetis-dev \
&& apt-get install -y --no-install-recommends \
tzdata \
python3.9 \
python3.9-dev \
python3.9-distutils \
python3-pip \
&& apt-get install -y --no-install-recommends \
python3-pydot python3-pydot-ng graphviz \
&& bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh 10 \
&& ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config \
&& rm -rf /var/lib/apt/lists/*

ENV LLVM_CONFIG /usr/bin/llvm-config-10


COPY ./dist/pyproject.toml /src/pyproject.toml
COPY ./dist/README.md /src/README.md
COPY ./dist/siml /src/siml
# COPY ./poetry.lock /src/poetry.lock
WORKDIR /src

# python path
ENV PYTHONPATH "$PYTHONPATH:/usr/lib/python3.9/site-packages"

# poerty
ENV PATH "$PATH:/root/.local/bin"

# Default version of python3 is python3.8.
# When virtual environment is not created by poetry,
# poetry use default version of python.
# In order to change default python version to python3.9,
# create symbolic link of python3.9
RUN curl -sSL https://install.python-poetry.org | python3.9 - \
&& unlink /usr/bin/python3 \
&& ln -s /usr/bin/python3.9 /usr/bin/python3 \
&& python3.9 -m pip install -U pip \
&& python3.9 -m pip install -U setuptools \
&& python3.9 -m pip install -U wheel \
&& python3.9 -m pip install --ignore-installed -U PyYAML \
&& python3.9 -m pip install Cython \
&& poetry config virtualenvs.create false \
&& poetry install \
&& poetry run python3 -m pip install torch==1.10.1 torchvision==0.11.2 -f https://download.pytorch.org/whl/cpu/torch_stable.html \
&& poetry run python3 -m pip install torch-scatter==2.0.9 -f https://pytorch-geometric.com/whl/torch-1.10.1+cpu.html \
&& poetry run python3 -m pip install torch-sparse==0.6.13 -f https://pytorch-geometric.com/whl/torch-1.10.1+cpu.html \
&& poetry run python3 -m pip install torch-cluster==1.6.0 -f https://pytorch-geometric.com/whl/torch-1.10.1+cpu.html \
&& poetry run python3 -m pip install torch-spline-conv==1.2.1 -f https://pytorch-geometric.com/whl/torch-1.10.1+cpu.html \
&& poetry run python3 -m pip install torch-geometric==2.2.0 \
&& poetry run python3 -m pip install -U "numpy<1.24"
21 changes: 16 additions & 5 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,30 @@ build: Dockerfile
mkdir dist
cp ../pyproject.toml ../README.md ./dist
cp -r ../siml ./dist
find ./dist/siml | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
docker build -t $(CI_REGISTRY_IMAGE):$(TAG) \
-f Dockerfile .

build_cpu:
rm -r ./dist || true
mkdir dist
cp ../pyproject.toml ../README.md ./dist
cp -r ../siml ./dist \
&& find ./dist/siml | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
docker build -t $(CI_REGISTRY_IMAGE)/cpu:$(TAG) \
-f Dockerfile_cpu .

in: build
docker run -it --gpus all --rm $(CI_REGISTRY_IMAGE):$(TAG) /bin/bash

push: login build
push: login build build_cpu
docker push $(CI_REGISTRY_IMAGE):$(TAG)
docker push $(CI_REGISTRY_IMAGE)/cpu:$(TAG)

ghcr: ghcr_login build
docker build -t $(GHCR_IMAGE):$(TAG) \
-f Dockerfile --build-arg ricos_pypi_key=$(key) .
docker push $(GHCR_IMAGE):$(TAG)
ghcr: ghcr_login
docker pull $(CI_REGISTRY_IMAGE)/cpu:$(TAG)
docker tag $(CI_REGISTRY_IMAGE)/cpu:$(TAG) $(GHCR_IMAGE)/cpu:$(TAG)
docker push $(GHCR_IMAGE)/cpu:$(TAG)

ghcr_login:
docker login $(GHCR_IMAGE)

0 comments on commit 6ad02ac

Please sign in to comment.