Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: Set up for building our image and running tests/code #212

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu

ENV HOME_DIR /home/pk

# Install base utilities.
RUN apt-get update \
&& apt-get install -y build-essential \
&& apt-get install -y wget \
&& apt-get install -y git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# https://stackoverflow.com/questions/27701930/how-to-add-users-to-docker-container
RUN useradd --create-home --shell /bin/bash pk
USER pk
WORKDIR $HOME_DIR

# Install miniconda.
ENV CONDA_DIR $HOME_DIR/opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p $HOME_DIR/opt/conda

# Put conda on the path so we can use the command.
ENV PATH=$CONDA_DIR/bin:$PATH

# Get pykokkos.
RUN git clone https://github.com/kokkos/pykokkos-base

# Install dependencies.
RUN conda install -c conda-forge --yes mamba
RUN conda init
RUN mamba install -c conda-forge --yes --file pykokkos-base/requirements.txt
COPY requirements.txt /tmp/requirements.txt
RUN mamba install -c conda-forge --yes --file /tmp/requirements.txt
RUN cd pykokkos-base && python setup.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DENABLE_VIEW_RANKS=3 -DENABLE_CUDA=OFF -DENABLE_THREADS=OFF -DENABLE_OPENMP=ON
58 changes: 58 additions & 0 deletions pk
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

PROJECT="pykokkos"
TAG="latest"
CHOME="/home/pk"


# ----------
# Functions.

function docker_clean() {
# Clean docker containers and images (this function is
# aggressive and cleans a lot more than necessary). Run only
# if you know the risk.

docker ps -a | grep -v 'CONTA' | cut -f1 -d' ' | xargs -I xxx docker rm xxx
docker images | grep "${PROJECT}" | awk '{ print $3 }' | xargs -I xxx docker image rm xxx
docker images | grep '<none>' | awk '{ print $3 }' | xargs -I xxx docker image rm xxx
}

function docker_build() {
local -r tag="${1:-$TAG}"

[ -z "${tag}" ] && return 1
[ ! -f "Dockerfile" ] && return 1

docker build -t "${PROJECT}:${tag}" -f Dockerfile .
}

function test_cmd_container() {
( cd "${CHOME}/pykokkos"
python runtests.py )
}

function cmd_in_container() {
local -r name="${1}"

( cd "${CHOME}/pykokkos"
export PYTHONPATH=pykokkos:$PYTHONPATH
python "${name}" )
}

function run_example() {
local -r name="${1}"

[ -z "${name}" ] && \
{ echo "no example name provided"; return 1; }

docker run --volume $(pwd):"${CHOME}/pykokkos" \
"${PROJECT}" \
"${CHOME}/pykokkos/pk" "cmd_in_container" "${name}"
}

function run_tests() {
run_example "runtests.py"
}

"$@"
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pybind11>=2.11.1
cupy>=12.2.0
patchelf>=0.17.2
pytest>=7.4.3
python=3.11
Loading