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

treewide: Improve docker container build, CI caching and python dependencies #192

Merged
merged 130 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
ac99545
py: Consolidate python requirements into `pyproject.toml` file
fischeti Aug 29, 2024
9eb222a
py: Remove previous requirement files
fischeti Aug 29, 2024
ae5aad9
ci: Remove doc generation in internal CI
fischeti Aug 29, 2024
c0f2809
docs: Update guide
fischeti Aug 29, 2024
1a3e2f3
container: Copy `pyproject.toml`
fischeti Aug 29, 2024
ca2bf6f
container: Only install dependencies
fischeti Aug 30, 2024
5172c76
container: Get rid of deprecated `spike-dasm`
fischeti Aug 30, 2024
ebf36c5
container: Update actions
fischeti Aug 30, 2024
5261493
container: Copy necessary sources
fischeti Aug 30, 2024
40a8783
container: Fix minor warnings
fischeti Aug 30, 2024
6f9d7e4
REVERT: Use custom container
fischeti Aug 30, 2024
290193a
container: Install `docs` dependencies
fischeti Aug 30, 2024
c3892d6
py: Merge dependencies
fischeti Aug 30, 2024
6993529
Revert "ci: Remove doc generation in internal CI"
fischeti Aug 30, 2024
f68307d
ci: Don't run CI on draft PRs (twice)
fischeti Sep 2, 2024
0422633
ci: Build docker container on all branches
fischeti Sep 2, 2024
b317b15
ci: Cache docker container build
fischeti Sep 2, 2024
8a446f3
container: Install verilator with apt
fischeti Sep 2, 2024
28ff9b9
ci: Don't free up space
fischeti Sep 2, 2024
a170979
container: Clean up container
fischeti Sep 2, 2024
592e769
container: Clean up
fischeti Sep 2, 2024
f80178a
container: debug build
fischeti Sep 2, 2024
686a955
REVERT: Disable CI
fischeti Sep 2, 2024
f9eead1
container: debug
fischeti Sep 2, 2024
f389d5e
container: debug
fischeti Sep 2, 2024
e7f6b51
container: debug
fischeti Sep 2, 2024
d0b3c6c
container: Bump `verilator` to `5.020`
fischeti Sep 2, 2024
eb6f33d
container: Add `build-essential` again
fischeti Sep 2, 2024
938ed86
container: Clean up rust/banshee dependencies
fischeti Sep 2, 2024
ba5f7dc
container: Revert to ubuntu 22.04 again
fischeti Sep 2, 2024
b3b1caf
container: Install cmake like a normal human being
fischeti Sep 2, 2024
b06e96c
container: Use `noninteractive` flag again
fischeti Sep 2, 2024
d345b6a
container: Clean up
fischeti Sep 2, 2024
9293972
container: Revert back verilator install to source
fischeti Sep 2, 2024
959c4c2
container: Try again with Ubuntu 24.04
fischeti Sep 2, 2024
7160b7d
Revert "container: Revert back verilator install to source"
fischeti Sep 2, 2024
62d9cff
container: Use LLVM 15 for banshee
fischeti Sep 2, 2024
b560121
container: Try with env variable
fischeti Sep 2, 2024
01ac201
container: Fix banshee dependencies
fischeti Sep 2, 2024
0a16c41
container: Try setting environment variable for banshee
fischeti Sep 2, 2024
4d93d6f
container: Debug
fischeti Sep 2, 2024
6cff79b
container: Debug
fischeti Sep 2, 2024
f0dd9aa
container: Try installing cmake
fischeti Sep 2, 2024
7e7a99c
container: Some more dependencies for banshee
fischeti Sep 2, 2024
9b666b2
container: Debug
fischeti Sep 2, 2024
9eb8e97
container: Clean up
fischeti Sep 2, 2024
2eabffc
container: Try to copy python over
fischeti Sep 2, 2024
9160783
container: Move stuff around
fischeti Sep 2, 2024
09c299f
container: Move it around again
fischeti Sep 2, 2024
ed8d44f
container: Debug
fischeti Sep 2, 2024
e211e45
container: Use correct python and activate environment
fischeti Sep 2, 2024
d32f521
container: Use default python version
fischeti Sep 2, 2024
c539baf
container: Use `python3`
fischeti Sep 2, 2024
2ca3345
container: Revert back a lot of stuff
fischeti Sep 2, 2024
bfe20e2
container: Clean up
fischeti Sep 2, 2024
f3ecc11
container: banshee deps
fischeti Sep 2, 2024
24b497b
container: python deps
fischeti Sep 2, 2024
02a4e26
container: More python deps
fischeti Sep 2, 2024
1f22ab9
container: Install python with `apt` (again)
fischeti Sep 3, 2024
0299f32
container: Verilator dependencies
fischeti Sep 3, 2024
13856ec
container: More dependencies for verilator
fischeti Sep 3, 2024
be013ac
container: Fix python version
fischeti Sep 3, 2024
cccc555
ci: Try freeing up disk space before
fischeti Sep 3, 2024
b7fe2c0
container: Try verilator container
fischeti Sep 3, 2024
8b663d0
Revert "ci: Try freeing up disk space before"
fischeti Sep 3, 2024
549df75
container: Specify ubuntu version
fischeti Sep 3, 2024
03310f1
container: Banshee dependencies
fischeti Sep 3, 2024
30de53e
container: Debug verilator
fischeti Sep 3, 2024
c149641
container: Clean up
fischeti Sep 3, 2024
52dbf68
container: Install python with `venv`
fischeti Sep 3, 2024
b2f6f03
container: Add additional stage for python files
fischeti Sep 3, 2024
f5ef89a
container: Also install pip
fischeti Sep 3, 2024
fd0e4ab
container: Debug
fischeti Sep 3, 2024
ed15660
container: Debug
fischeti Sep 3, 2024
46dcb25
contaienr: Debug
fischeti Sep 3, 2024
45a916c
container: Debug
fischeti Sep 3, 2024
5cb109f
container: Disable cache for the moment
fischeti Sep 3, 2024
21e3edb
container: Debug
fischeti Sep 4, 2024
78448d4
container: Debug
fischeti Sep 4, 2024
d80a42f
Revert "Revert "ci: Try freeing up disk space before""
fischeti Sep 4, 2024
5bfca71
Revert "container: Disable cache for the moment"
fischeti Sep 4, 2024
a4ada4c
Revert "Revert "Revert "ci: Try freeing up disk space before"""
fischeti Sep 4, 2024
fe1686e
Revert "REVERT: Disable CI"
fischeti Sep 4, 2024
f9c0b5c
container: Set PATH variables correctly
fischeti Sep 4, 2024
46a08a6
ci: Update clang-lint action
fischeti Sep 4, 2024
48d21da
container: Move LLLM install to previous stage
fischeti Sep 4, 2024
3db37c8
ci: Don't run pip install anymore
fischeti Sep 4, 2024
4d0b2b6
ci: Build container before running verilator CI
fischeti Sep 4, 2024
d8eabaa
ci: Don't use container for linting
fischeti Sep 4, 2024
e7a4839
ci: Cache verilator build
fischeti Sep 4, 2024
a7efc65
ci: Free up disk space when building the container
fischeti Sep 4, 2024
a4d029b
ci: Don't run for draft requests
fischeti Sep 4, 2024
bdf23f8
lint: YAML sources
fischeti Sep 4, 2024
dd1315f
ci: Remove unused `bender vendor init`
fischeti Sep 4, 2024
b0d4001
Revert "ci: Don't run pip install anymore"
fischeti Sep 4, 2024
2ef9503
container: Add LLVM to path for `clang-format`
fischeti Sep 5, 2024
eb40790
container: Don't set `tools` as workdir
fischeti Sep 5, 2024
533696f
ci: Bump python and verilator version for IIS setup
fischeti Sep 5, 2024
05e9fdd
ci: fix syntax mistake
fischeti Sep 5, 2024
4a35a9c
container: Install `device-tree-compiler`
fischeti Sep 5, 2024
923b15b
container: Use verilator as base image for last stage
fischeti Sep 5, 2024
f33109c
sim: Fix verilator flags
fischeti Sep 5, 2024
87578a9
ci: Fix typo
fischeti Sep 5, 2024
9a6f4c8
ci: Fix working directory
fischeti Sep 5, 2024
2db8af9
container: Remove unused `apt-requirements.txt`
fischeti Sep 5, 2024
4c599d4
ci: Remove pip installs again
fischeti Sep 5, 2024
2cbfa20
ci: Separate `vlt-flist` with commas
fischeti Sep 5, 2024
c857499
ci: Correct flist for verilator build caching
fischeti Sep 5, 2024
c15ca10
ci: Try stripping
fischeti Sep 5, 2024
a412982
ci: Debug
fischeti Sep 5, 2024
3dfdbfc
ci: Use simpler file hashing for caching
fischeti Sep 5, 2024
4381f44
doc: Update container documentation
fischeti Sep 5, 2024
73510b5
ci: Revert publish doc
fischeti Sep 5, 2024
51dcd8e
ci: Also run on draft pull requests
fischeti Sep 5, 2024
a8d9358
ci: Run on internal push and external pull requests
fischeti Sep 5, 2024
fa2b1d6
ci: Linting
fischeti Sep 5, 2024
aae1a89
ci: Hash exact requirements of `bin/snitch_cluster.vlt`
colluca Sep 6, 2024
c6ef368
ci: Temporarily run `list-make-prerequisites` in debug mode
colluca Sep 6, 2024
01661e5
env: Fix python version
fischeti Sep 6, 2024
f68bfae
container: Merge run commands
fischeti Sep 6, 2024
08f4840
container: Use `.dockerignore` to filter python files
fischeti Sep 6, 2024
4f89a6f
ci: Use `list-make-prerequisites` action
colluca Sep 6, 2024
79a03df
container: Use `non-interactive` in every stage
fischeti Sep 10, 2024
25fc294
container: Replace `apt` with `apt-get`
fischeti Sep 10, 2024
3ce3048
ci: Use `build-docker` workflow as dependency for other workflows
fischeti Sep 10, 2024
d1cf2d0
ci: Don't run `build-docker` for `pull_requests`
fischeti Sep 10, 2024
c48bc10
Revert "ci: Don't run `build-docker` for `pull_requests`"
fischeti Sep 10, 2024
e78d17b
Revert "ci: Use `build-docker` workflow as dependency for other workf…
fischeti Sep 10, 2024
8add931
ci: Move sources-up-to-date job from lint to ci
colluca Sep 26, 2024
f46b68d
ci: Temporarily remove Banshee due to dependency error
colluca Sep 27, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/build-docker.yml
colluca marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
- name: Disk usage after freeing up space
run: df -h
# Actually build the Docker container
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: GHCR Log-in
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
context: .
file: util/container/Dockerfile
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
fischeti marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Build documentation
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v2
- name: Build docs
Expand All @@ -29,7 +29,7 @@ jobs:
name: Python unit tests
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v2
- name: Run pytest
Expand All @@ -43,7 +43,7 @@ jobs:
name: Simulate SW on Snitch Cluster w/ Verilator
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
name: Simulate SW on Snitch Cluster w/ Banshee
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
name: Check Sources Up-to-Date
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Deploy documentation
runs-on: ubuntu-22.04
container:
image: ghcr.io/pulp-platform/snitch_cluster:main
image: ghcr.io/pulp-platform/snitch_cluster:pyproject
steps:
- uses: actions/checkout@v2
# For some reason, the checkout is done by a different user,
Expand Down
8 changes: 0 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ variables:
before_script:
source iis-setup.sh

##############
# Build docs #
##############

docs:
script:
- make docs

fischeti marked this conversation as resolved.
Show resolved Hide resolved
#####################
# Python unit tests #
#####################
Expand Down
11 changes: 0 additions & 11 deletions docs/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/ug/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ theme](https://squidfunk.github.io/mkdocs-material/). Before building the
documentation, make sure you have the required dependencies installed:

```shell
pip install -r docs/requirements.txt
pip install .[docs]
```

After everything is installed, you can build a static copy of the `html` documentation by
Expand Down
10 changes: 4 additions & 6 deletions iis-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ export LLVM_BINROOT=/usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin
# Create Python virtual environment with required packages
/usr/local/anaconda3-2022.05/bin/python3 -m venv .venv
source .venv/bin/activate
# Unpack packages in a local temporary directory which can be safely cleaned
# after installation. Also protects against "No space left on device" errors
# Install local packages in editable mode and unpack packages in a
# local temporary directory which can be safely cleaned after installation.
# Also protects against "No space left on device" errors
# occurring when the /tmp folder is filled by other processes.
mkdir tmp
TMPDIR=tmp pip install -r python-requirements.txt
TMPDIR=tmp pip install -e .
rm -rf tmp

# Install local packages in editable mode.
pip install -e .
48 changes: 46 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: SHL-0.51

[build-system]
requires = ["setuptools>=42"]
requires = ["setuptools>=64"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -12,8 +12,52 @@ authors = [
{name = "Luca Colagrande", email = "[email protected]"}
]
dynamic = ["version"]
dependencies = [
# Keep sorted.
# General dependencies.
"bin2coe",
"dataclasses",
"editorconfig-checker==2.3.51",
"flake8",
"gitpython",
"hjson",
"humanize",
"json5",
"jsonref",
"jsonschema",
"mako",
"matplotlib",
"mkdocs-material",
"pandas",
"prettytable",
"progressbar2",
"psutil",
"pyelftools",
"pyflexfloat",
"pytablewriter",
"pytest",
"pyyaml",
"scikit-learn",
"tabulate",
"termcolor",
"yamllint",
# DNN lib dependencies.
"numpy",
"torch",
"json5"
fischeti marked this conversation as resolved.
Show resolved Hide resolved
]

[project.optional-dependencies]
docs = [
"mkdocs",
"mkdocs-material",
"mkdocs-include-markdown-plugin",
"mkdocs-macros-plugin",
"mkdocstrings",
"mkdocstrings-python",
]

[tool.setuptools.package-dir]
"snitch.dnn" = "sw/dnn"
"snitch.blas" = "sw/blas"
"snitch.util" = "util"
"snitch.util" = "util"
34 changes: 0 additions & 34 deletions python-requirements.txt

This file was deleted.

7 changes: 0 additions & 7 deletions sw/dnn/requirements.txt

This file was deleted.

35 changes: 15 additions & 20 deletions util/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN cd Python-${PYTHON_VERSION} && \

# Build Rust tools
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH "/root/.cargo/bin:${PATH}"
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install 1.70.0
RUN rustup override set 1.70.0

Expand All @@ -75,7 +75,7 @@ WORKDIR /tools
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \
tar -x -f cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz --strip-components=1 -C . && \
rm -rf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz
ENV PATH "/tools/bin:${PATH}"
ENV PATH="/tools/bin:${PATH}"

# Install `banshee` (needs cmake)
RUN rustup install 1.67.0
Expand All @@ -87,10 +87,6 @@ RUN cargo install --path /tmp/banshee
RUN wget https://github.com/pulp-platform/bender/releases/download/v${BENDER_VERSION}/bender-${BENDER_VERSION}-x86_64-linux-gnu-ubuntu18.04.tar.gz
RUN tar xzf bender-${BENDER_VERSION}-x86_64-linux-gnu-ubuntu18.04.tar.gz

# Install spike-dasm
RUN wget https://github.com/pulp-platform/riscv-isa-sim/releases/download/snitch-v${SPIKE_DASM_VERSION}/snitch-spike-dasm-${SPIKE_DASM_VERSION}-x86_64-linux-gnu-ubuntu18.04.tar.gz
RUN tar xzf snitch-spike-dasm-${SPIKE_DASM_VERSION}-x86_64-linux-gnu-ubuntu18.04.tar.gz

# Install Doxygen
RUN wget https://www.doxygen.nl/files/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
RUN tar xzf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
Expand All @@ -104,7 +100,7 @@ ARG VERIBLE_VERSION=0.0-3318-g8d254167
LABEL version="0.1"
LABEL description="Snitch container for hardware and software development."
LABEL maintainer="[email protected]"
LABEL org.opencontainers.image.source https://github.com/pulp-platform/snitch_cluster
LABEL org.opencontainers.image.source=https://github.com/pulp-platform/snitch_cluster

WORKDIR /tools

Expand Down Expand Up @@ -135,13 +131,13 @@ RUN latest_tag=`curl -s -H "Accept: application/vnd.github.v3+json" https://api.
echo "SNITCH_LLVM_VERSION=${SNITCH_LLVM_VERSION} LLVM_TAR=${LLVM_TAR} latest_tag=${latest_tag}" && \
wget -qO- https://github.com/pulp-platform/llvm-project/releases/download/${SNITCH_LLVM_VERSION}/${LLVM_TAR} | \
tar xvz --strip-components=1 -C riscv-llvm
ENV LLVM_BINROOT "/tools/riscv-llvm/bin"
ENV LLVM_BINROOT="/tools/riscv-llvm/bin"

# Install Verible
RUN wget https://github.com/chipsalliance/verible/releases/download/v${VERIBLE_VERSION}/verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz && \
tar -x -f verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz --strip-components=1 -C . && \
rm -rf verible-v${VERIBLE_VERSION}-linux-static-x86_64.tar.gz
ENV PATH "/tools/bin:${PATH}"
ENV PATH="/tools/bin:${PATH}"

# Install git>=2.18, required by Github checkout action to recurse submodules
RUN apt-get update && apt-get install software-properties-common -y && \
Expand All @@ -151,27 +147,26 @@ RUN apt-get update && apt-get install software-properties-common -y && \

# Copy artifacts from stage 1.
COPY --from=builder /tools/bender bin/
COPY --from=builder /tools/spike-dasm bin/
COPY --from=builder /root/.cargo/bin/banshee bin/
COPY --from=builder /opt/python /opt/python
COPY --from=builder /tools/verilator /tools/verilator/
COPY --from=builder /tools/doxygen/bin/doxygen bin/

# Create and activate virtual environment
ENV VIRTUAL_ENV "/root/.venvs/snitch_cluster"
ENV VIRTUAL_ENV="/root/.venvs/snitch_cluster"
RUN /opt/python/bin/python3 -m venv ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
# Install Python requirements
COPY python-requirements.txt /tmp/python-requirements.txt
COPY docs/requirements.txt /tmp/docs/requirements.txt
COPY sw/dnn/requirements.txt /tmp/sw/dnn/requirements.txt
RUN pip install -r /tmp/python-requirements.txt

COPY pyproject.toml .
COPY sw/dnn ./sw/dnn
COPY sw/blas ./sw/blas
COPY util ./util
RUN pip install .[docs]
# Add Verilator to PATH
ENV PATH "/tools/verilator/bin:${PATH}"
ENV VLT_ROOT "/tools/verilator/share/verilator/"
ENV PATH="/tools/verilator/bin:${PATH}"
ENV VLT_ROOT="/tools/verilator/share/verilator/"

# Set locale to UTF-8, required because Python 3.6 defaults on ASCII encoding.
# See https://click.palletsprojects.com/en/8.1.x/unicode-support/
ENV LC_ALL "C.UTF-8"
ENV LANG "C.UTF-8"
ENV LC_ALL="C.UTF-8"
ENV LANG="C.UTF-8"
Loading