Skip to content

Commit

Permalink
[ci] Add Dockerfile to support minimum CPU (taichi-dev#3277)
Browse files Browse the repository at this point in the history
* Add Dockerfile to support minimum cpu

* Add image for 18.04
  • Loading branch information
qiao-bo authored Oct 29, 2021
1 parent 3473264 commit d584b08
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
58 changes: 58 additions & 0 deletions ci/Dockerfile.Ubuntu.18.04.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Taichi Dockerfile for development
FROM ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive
LABEL maintainer="https://github.com/taichi-dev"

RUN apt-get update && \
apt-get install -y software-properties-common \
python3-pip \
libtinfo-dev \
clang-10 \
wget \
git \
unzip \
zlib1g-dev \
libx11-xcb-dev

# Install the latest version of CMAKE v3.20.5 from source
WORKDIR /
RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-linux-x86_64.tar.gz
RUN tar xf cmake-3.20.5-linux-x86_64.tar.gz && \
rm cmake-3.20.5-linux-x86_64.tar.gz
ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH"

# Intall LLVM 10
WORKDIR /
# Make sure this URL gets updated each time there is a new prebuilt bin release
RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip
RUN unzip taichi-llvm-10.0.0-linux.zip && \
rm taichi-llvm-10.0.0-linux.zip
ENV PATH="/taichi-llvm-10.0.0-linux/bin:$PATH"
# Use Clang as the default compiler
ENV CC="clang-10"
ENV CXX="clang++-10"

# Create non-root user for running the container
RUN useradd -ms /bin/bash dev
WORKDIR /home/dev
USER dev

# Install miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -p /home/dev/miniconda -b
ENV PATH="/home/dev/miniconda/bin:$PATH"

# Set up multi-python environment
RUN conda init bash
RUN conda create -n py36 python=3.6 -y
RUN conda create -n py37 python=3.7 -y
RUN conda create -n py38 python=3.8 -y
RUN conda create -n py39 python=3.9 -y

# Load scripts for build and test
WORKDIR /home/dev/scripts
COPY ci/scripts/ubuntu_build_test_cpu.sh ubuntu_build_test_cpu.sh

WORKDIR /home/dev
ENV LANG="C.UTF-8"
57 changes: 57 additions & 0 deletions ci/Dockerfile.Ubuntu.20.04.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Taichi Dockerfile for development
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
LABEL maintainer="https://github.com/taichi-dev"

RUN apt-get update && \
apt-get install -y software-properties-common \
python3-pip \
libtinfo-dev \
clang-10 \
wget \
git \
unzip \
libx11-xcb-dev

# Install the latest version of CMAKE v3.20.5 from source
WORKDIR /
RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-linux-x86_64.tar.gz
RUN tar xf cmake-3.20.5-linux-x86_64.tar.gz && \
rm cmake-3.20.5-linux-x86_64.tar.gz
ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH"

# Intall LLVM 10
WORKDIR /
# Make sure this URL gets updated each time there is a new prebuilt bin release
RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip
RUN unzip taichi-llvm-10.0.0-linux.zip && \
rm taichi-llvm-10.0.0-linux.zip
ENV PATH="/taichi-llvm-10.0.0-linux/bin:$PATH"
# Use Clang as the default compiler
ENV CC="clang-10"
ENV CXX="clang++-10"

# Create non-root user for running the container
RUN useradd -ms /bin/bash dev
WORKDIR /home/dev
USER dev

# Install miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -p /home/dev/miniconda -b
ENV PATH="/home/dev/miniconda/bin:$PATH"

# Set up multi-python environment
RUN conda init bash
RUN conda create -n py36 python=3.6 -y
RUN conda create -n py37 python=3.7 -y
RUN conda create -n py38 python=3.8 -y
RUN conda create -n py39 python=3.9 -y

# Load scripts for build and test
WORKDIR /home/dev/scripts
COPY ci/scripts/ubuntu_build_test_cpu.sh ubuntu_build_test_cpu.sh

WORKDIR /home/dev
ENV LANG="C.UTF-8"
33 changes: 33 additions & 0 deletions ci/scripts/ubuntu_build_test_cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -ex

# Parse ARGs
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
case "$KEY" in
SHA) SHA=${VALUE} ;;
PY) PY=${VALUE} ;;
*)
esac
done

source /home/dev/miniconda/etc/profile.d/conda.sh
conda activate $PY

# Build Taichi from source
git clone --recursive https://github.com/taichi-dev/taichi --branch=master
cd taichi
git checkout $SHA
python3 -m pip install -r requirements_dev.txt -i http://repo.taichigraphics.com/repository/pypi/simple --trusted-host repo.taichigraphics.com
TAICHI_CMAKE_ARGS="-DTI_WITH_VULKAN:BOOL=OFF -DTI_WITH_CUDA:BOOL=OFF -DTI_WITH_OPENGL:BOOL=OFF" python3 setup.py install

# Add Docker specific ENV
export TI_IN_DOCKER=true

# Run tests
ti diagnose
ti test -vr2 -t2 -k "not ndarray and not torch"
ti test -vr2 -t1 -k "ndarray or torch"

0 comments on commit d584b08

Please sign in to comment.