Skip to content

Commit

Permalink
Packaging fixes (#2355)
Browse files Browse the repository at this point in the history
Signed-off-by: Bettina Heim <heimb@outlook.com>
  • Loading branch information
bettinaheim authored Nov 6, 2024
1 parent a69a877 commit ea9bb97
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 24 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
platform_tag: ${{ steps.info.outputs.platform_tag }}
build_docs: ${{ steps.info.outputs.build_docs }}
push_to_ngc: ${{ steps.info.outputs.push_to_ngc }}
is_versioned: ${{ steps.info.outputs.is_versioned }}

# Needed to define metadata depending on whether an environment secret is defined.
environment:
Expand All @@ -62,10 +63,10 @@ jobs:
# multi-platform builds get no platform tag
echo "runner=linux-amd64-cpu8" >> $GITHUB_OUTPUT
echo "build_docs=${{ inputs.build_docs != 'false' }}" >> $GITHUB_OUTPUT
is_versioned=${{ github.ref_type == 'tag' || github.ref_name == 'main' || startsWith(github.ref_name, 'releases/') }}
is_staging_branch=${{ startsWith(github.ref_name, 'staging/') }}
is_experimental=${{ startsWith(github.ref_name, 'experimental/') }}
push_to_ngc=`${{ inputs.environment && secrets.NGC_CREDENTIALS != '' }} && ($is_versioned || $is_staging_branch || $is_experimental) && echo true || echo`
is_versioned=${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') || startsWith(github.ref_name, 'staging/') }}
has_continuous_deployment=${{ startsWith(github.ref_name, 'experimental/') || github.ref_name == 'main' }}
push_to_ngc=`${{ inputs.environment && secrets.NGC_CREDENTIALS != '' }} && ($is_versioned || $has_continuous_deployment) && echo true || echo`
echo "is_versioned=$is_versioned" >> $GITHUB_OUTPUT
echo "push_to_ngc=$push_to_ngc" >> $GITHUB_OUTPUT
elif [ -n "$(echo ${{ inputs.platforms }} | grep -i arm)" ]; then
platform_tag=`echo ${{ inputs.platforms }} | sed 's/linux\///g' | tr -d ' '`
Expand Down Expand Up @@ -481,7 +482,7 @@ jobs:
image_tag+=pr-${pr_number:-${{ github.event.pull_request.number }}}
elif ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}; then
image_tag+=latest
elif ${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') }}; then
elif ${{ needs.metadata.outputs.is_versioned == 'true' }}; then
image_tag+=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
else
image_tag+=`echo ${{ github.ref_name }} | tr '/' '-'`
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/prebuilt_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ jobs:
id: config
run: |
platform_tag=`echo ${{ inputs.platform }} | sed 's/linux\///g' | tr -d ' '`
if ${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') }}; then
is_versioned=${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') || startsWith(github.ref_name, 'staging/') }}
if ${is_versioned}; then
cudaq_version=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
else
cudaq_version=0.0.0
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ jobs:
fi
done
# Version number of the Python wheels
if ${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') }}; then
# CUDA-Q version number
is_versioned=${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') || startsWith(github.ref_name, 'staging/') }}
if ${is_versioned}; then
cudaq_version=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
else
cudaq_version=${release_version:-0.0.0}
Expand Down Expand Up @@ -737,7 +738,7 @@ jobs:

strategy:
matrix:
os_image: ['redhat/ubi9:9.2', 'ubuntu:22.04']
os_image: ['redhat/ubi8:8.0', 'ubuntu:22.04']
cuda_version: ['11.8', '12.0']
fail-fast: false

Expand All @@ -756,7 +757,7 @@ jobs:

- name: Configure validation
id: config
run:
run: |
cuda_major=`echo ${{ matrix.cuda_version }} | cut -d . -f1`
echo "cuda_major=$cuda_major" >> $GITHUB_OUTPUT
Expand All @@ -780,13 +781,19 @@ jobs:
libcublas-$cuda_version_suffix \
cuda-cudart-$cuda_version_suffix \
libcusolver-$cuda_version_suffix
if [ $(echo ${{ matrix.cuda_version }} | cut -d . -f1) -gt 11 ]; then
apt-get install -y --no-install-recommends \
libnvjitlink-$cuda_version_suffix
fi
- name: Runtime dependencies (dnf)
if: startsWith(matrix.os_image, 'redhat')
run: |
dnf install -y --nobest --setopt=install_weak_deps=False \
'dnf-command(config-manager)' glibc-devel openssh-clients
CUDA_VERSION=${{ matrix.cuda_version }} . scripts/configure_build.sh install-cudart
CUDA_VERSION=${{ matrix.cuda_version }}
DISTRIBUTION=rhel8
. scripts/configure_build.sh install-cudart
# We need to install an MPI implementation, otherwise nothing
# will be able to run on the nvidia-mgpu backend.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/python_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ jobs:
cache_id=`echo ${{ inputs.python_version }}-$devenv_tag | tr . -`
mkdir -p "/tmp/wheels"
if ${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') }}; then
is_versioned=${{ github.ref_type == 'tag' || startsWith(github.ref_name, 'releases/') || startsWith(github.ref_name, 'staging/') }}
if ${is_versioned}; then
cudaq_version=`echo ${{ github.ref_name }} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}"`
else
cudaq_version=0.0.0
Expand Down
4 changes: 2 additions & 2 deletions docker/build/devdeps.ext.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# docker build -t ghcr.io/nvidia/cuda-quantum-devdeps:ext -f docker/build/devdeps.ext.Dockerfile .

ARG cuda_version=11.8
ARG base_image=ghcr.io/nvidia/cuda-quantum-devdeps:llvm-main
ARG base_image=ghcr.io/nvidia/cuda-quantum-devdeps:gcc11-main
ARG ompidev_image=ghcr.io/nvidia/cuda-quantum-devdeps:cu11-ompi-main
FROM $ompidev_image AS ompibuild
ARG cuda_version
Expand Down Expand Up @@ -155,7 +155,7 @@ ENV CUTENSOR_ROOT="$CUTENSOR_INSTALL_PREFIX"
ENV LD_LIBRARY_PATH="$CUTENSOR_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH"
ENV CPATH="$CUTENSOR_INSTALL_PREFIX/include:$CPATH"

ENV CUTENSOR_VERSION=2.0.1.2
ENV CUTENSOR_VERSION=2.0.2.5
RUN apt-get update && apt-get install -y --no-install-recommends xz-utils \
&& arch_folder=$([ "$(uname -m)" == "aarch64" ] && echo sbsa || echo x86_64) \
&& cuda_major=$(echo $CUDA_VERSION | cut -d . -f1) \
Expand Down
14 changes: 9 additions & 5 deletions docker/release/cudaq.ext.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

ARG base_image=nvcr.io/nvidia/nightly/cuda-quantum:latest-base
ARG base_image=nvcr.io/nvidia/nightly/cuda-quantum:cu11-latest-base
FROM $base_image

USER root
Expand All @@ -29,10 +29,14 @@ RUN if [ -d "$CUDA_QUANTUM_PATH/assets/documentation" ]; then \
&& rm -rf "$CUDA_QUANTUM_PATH/assets" "$CUDA_QUANTUM_PATH/bin/migrate_assets.sh"

# Install additional runtime dependencies.
RUN apt-get install -y --no-install-recommends \
libcusolver-11-8 libcublas-11-8 cuda-cudart-11-8 \
# just here for convenience:
curl jq
RUN cuda_version_suffix=$(echo $CUDA_VERSION | tr . -) && \
for cudart_dependency in libcusolver libcublas cuda-cudart; do \
if [ -z "$(apt list --installed | grep -o ${cudart_dependency}-${cuda_version_suffix})" ]; then \
apt-get install -y --no-install-recommends ${cudart_dependency}-${cuda_version_suffix}; \
fi \
done && \
# just here for convenience:
apt-get install -y --no-install-recommends curl jq
RUN if [ -x "$(command -v pip)" ]; then \
apt-get install -y --no-install-recommends gcc libpython3-dev \
&& pip install --no-cache-dir jupyterlab; \
Expand Down
4 changes: 3 additions & 1 deletion docker/release/cudaq.wheel.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ RUN echo "Building wheel for python${python_version}." \
CUDACXX="$CUDA_INSTALL_PREFIX/bin/nvcc" CUDAHOSTCXX=$CXX \
$python -m build --wheel \
&& cudaq_major=$(echo ${CUDA_VERSION} | cut -d . -f1) \
&& cudart_libsuffix=$([ "$cuda_major" == "11" ] && echo "11.0" || echo "12") \
&& $python -m pip install --no-cache-dir auditwheel \
&& LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/_skbuild/lib" \
$python -m auditwheel -v repair dist/cuda_quantum*linux_*.whl \
Expand All @@ -69,7 +70,8 @@ RUN echo "Building wheel for python${python_version}." \
--exclude libcusolver.so.$cudaq_major \
--exclude libcutensor.so.2 \
--exclude libnvToolsExt.so.1 \
--exclude libcudart.so.$cudaq_major.0
--exclude libcudart.so.$cudart_libsuffix \
--exclude libnvidia-ml.so.1

FROM scratch
COPY --from=wheelbuild /cuda-quantum/wheelhouse/*manylinux*.whl .
5 changes: 4 additions & 1 deletion docker/test/installer/runtime_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ case $1 in
esac

CUDA_DOWNLOAD_URL=https://developer.download.nvidia.com/compute/cuda/repos
CUDA_ARCH_FOLDER=$([ "$(uname -m)" == "aarch64" ] && echo sbsa || echo x86_64)
CUDA_VERSION_SUFFIX=$(echo ${CUDART_VERSION:-'11.8'} | tr . -)
CUDA_PACKAGES=$(echo "cuda-cudart libcusolver libcublas" | sed "s/[^ ]*/&-${CUDA_VERSION_SUFFIX} /g")
CUDA_ARCH_FOLDER=$([ "$(uname -m)" == "aarch64" ] && echo sbsa || echo x86_64)
if [ $(echo ${CUDART_VERSION} | cut -d . -f1) -gt 11 ]; then
CUDA_PACKAGES+=" libnvjitlink-${CUDA_VERSION_SUFFIX}"
fi

if [ "$pkg_manager" == "apt-get" ]; then
## [Prerequisites]
Expand Down
4 changes: 4 additions & 0 deletions scripts/configure_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ if [ "$1" == "install-cudart" ]; then
cuda-cudart-${version_suffix} \
libcusolver-${version_suffix} \
libcublas-${version_suffix}
if [ $(echo ${CUDA_VERSION} | cut -d . -f1) -gt 11 ]; then
dnf install -y --nobest --setopt=install_weak_deps=False \
libnvjitlink-${version_suffix}
fi
# [<CUDARTInstall]
fi

Expand Down
4 changes: 3 additions & 1 deletion scripts/validate_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ echo "============================="
# Note: some of the tests do their own "!pip install ..." during the test, and
# for that to work correctly on the first time, the user site directory (e.g.
# ~/.local/lib/python3.10/site-packages) must already exist, so create it here.
mkdir -p $(python3 -m site --user-site)
if [ -x "$(command -v python3)" ]; then
mkdir -p $(python3 -m site --user-site)
fi
# Note divisive_clustering_src is not currently in the Published container under
# the "examples" folder, but the Publishing workflow moves all examples from
Expand Down
4 changes: 2 additions & 2 deletions scripts/validate_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fi
# Execute instructions from the README file
conda_script="$(awk '/(Begin conda install)/{flag=1;next}/(End conda install)/{flag=0}flag' "$readme_file" | grep . | sed '/^```/d')"
while IFS= read -r line; do
line=${line//3.10/$python_version}
line=${line//pip install cuda-quantum/pip install "$cudaq_wheel"}
line=$(echo $line | sed -E "s/python(=)?3.[0-9]{1,}/python\13.10/g")
line=$(echo $line | sed -E "s/pip install cuda-quantum-cu[0-9]{2,}/pip install \"$cudaq_wheel\"/g")
if [ -n "$(echo $line | grep "conda activate")" ]; then
conda_env=$(echo "$line" | sed "s#conda activate##" | tr -d '[:space:]')
source $(conda info --base)/bin/activate $conda_env
Expand Down

0 comments on commit ea9bb97

Please sign in to comment.