Skip to content

Commit

Permalink
Add preliminary sparsify Dockerfile (#234)
Browse files Browse the repository at this point in the history
* Dockerfile with Workflow files

* Upgrade pip

* Add empty last line
  • Loading branch information
rahul-tuli authored Jul 6, 2023
1 parent 3080de7 commit 9e78466
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 20 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build and Publish Sparsify Release Docker Images

on:
release:
types: [published]

jobs:
build-and-push-docker-image:
name: Build and Push Version Tagged Docker Images to GitHub Container Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Cleanup disk
run: |
sudo ls -l /usr/local/lib/
sudo ls -l /usr/share/
sudo du -sh /usr/local/lib/
sudo du -sh /usr/share/
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo du -sh /usr/local/lib/
sudo du -sh /usr/share/
- name: Set up Docker Buildx
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Login to Github Packages
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout code
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Get Tag
id: extract_tag
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF_NAME#*/})"

- name: Current Version Name
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
echo ${{ steps.extract_tag.outputs.tag }}
- name: Build and push sparsify release ${{ steps.extract_tag.outputs.tag }} docker image
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v2
with:
context: ./docker
build-args: |
REF=release/${{ steps.extract_tag.outputs.tag }}
push: true
tags: |
ghcr.io/neuralmagic/sparsify:${{ steps.extract_tag.outputs.tag }}
- name: Image digest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: echo ${{ steps.docker_build.outputs.digest }}
58 changes: 58 additions & 0 deletions .github/workflows/build-nightly-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Publish Sparsify Release Docker Images

on:
push:
branches:
- 'main'

jobs:
build-and-push-docker-image:
name: Build and Push Version Tagged Docker Images to GitHub Container Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Cleanup disk
run: |
sudo ls -l /usr/local/lib/
sudo ls -l /usr/share/
sudo du -sh /usr/local/lib/
sudo du -sh /usr/share/
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo du -sh /usr/local/lib/
sudo du -sh /usr/share/
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Build and push sparsify-nightly docker image
uses: docker/build-push-action@v2
with:
context: ./docker
build-args: |
REF=main
push: true
tags: |
ghcr.io/neuralmagic/sparsify-nightly:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
30 changes: 10 additions & 20 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# Setup the base image
FROM python:3.8-slim-bullseye
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04

# Install git
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ARG DEBIAN_FRONTEND=noninteractive

# Activate venv
RUN python3.8 -m venv /venv
ENV PATH="venv/bin:$PATH"
RUN apt-get update && apt-get install --no-install-recommends -y \
git python3 python3-dev python3-venv python3-pip python3-wheel build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade setuptools wheel

# Setup DeepSparse
ARG REF=main
RUN git clone https://github.com/neuralmagic/sparsify && cd sparsify && git checkout $REF
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir -e ./sparsify

ARG GIT_CHECKOUT
# if $GIT_CHECKOUT is not specified - just install from pypi
RUN if [ -z "${GIT_CHECKOUT}" ] ; then pip3 install --no-cache-dir --upgrade deepsparse[server] ; fi

# if $GIT_CHECKOUT is specified - clone, checkout $GIT_CHECKOUT, and install with -e
RUN if [ -n "${GIT_CHECKOUT}" ] ; then git clone https://github.com/neuralmagic/deepsparse.git --depth 1 -b $GIT_CHECKOUT; fi
RUN if [ -n "${GIT_CHECKOUT}" ] ; then pip3 install --no-cache-dir --upgrade -e "./deepsparse[server]" ; fi
CMD ["/bin/bash"]

0 comments on commit 9e78466

Please sign in to comment.