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

Improve Dockerfile robustness #722

Merged
merged 47 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2219678
Update dockerfile
vincentmr May 10, 2024
f9c92e8
Install github PL version.
vincentmr May 10, 2024
42fb319
Auto update version from '0.37.0-dev6' to '0.37.0-dev7'
ringo-but-quantum May 10, 2024
312ba73
Introduce PENNYLANE_VERSION
vincentmr May 10, 2024
e3c7337
Fix ARG PENNYLANE_VERSION
vincentmr May 10, 2024
cf6695c
Change inputs messages.
vincentmr May 10, 2024
d2ca47d
Bump Kokkos version
mlxd May 10, 2024
023fc16
Auto update version from '0.37.0-dev6' to '0.37.0-dev8'
ringo-but-quantum May 10, 2024
a30af9c
Merge branch 'master' into update/kokkos_version
mlxd May 10, 2024
3fd6469
Auto update version from '0.37.0-dev8' to '0.37.0-dev9'
ringo-but-quantum May 10, 2024
66d25b2
Merge branch 'master' into update/kokkos_version
mlxd May 14, 2024
3b0888c
Replace all Kokkos versions with 4.3 to update cache
mlxd May 14, 2024
2a7312f
Merge branch 'master' into update/kokkos_version
mlxd May 14, 2024
575dbaa
Auto update version from '0.37.0-dev9' to '0.37.0-dev10'
ringo-but-quantum May 14, 2024
1e2d004
Merge branch 'master' into update/dockerfile
vincentmr May 14, 2024
e79e450
Auto update version from '0.37.0-dev9' to '0.37.0-dev10'
ringo-but-quantum May 14, 2024
9e8a7ac
Merge branch 'master' into update/dockerfile
vincentmr May 15, 2024
12dcdc6
Auto update version from '0.37.0-dev11' to '0.37.0-dev12'
ringo-but-quantum May 15, 2024
395587b
Update changelog
mlxd May 15, 2024
7ec53bd
Merge branch 'master' into update/kokkos_version
mlxd May 15, 2024
3a7bec2
Auto update version from '0.37.0-dev11' to '0.37.0-dev12'
ringo-but-quantum May 15, 2024
5925a83
Update .github/workflows/docker_linux_x86_64.yml
vincentmr May 15, 2024
11ca23a
Update .github/workflows/docker_linux_x86_64.yml [skip ci]
vincentmr May 15, 2024
8640687
Auto update version from '0.37.0-dev12' to '0.37.0-dev13'
ringo-but-quantum May 15, 2024
960567c
Merge branch 'master' of github.com:PennyLaneAI/pennylane-lightning i…
mlxd May 15, 2024
6ec8d67
Auto update version from '0.37.0-dev12' to '0.37.0-dev13'
ringo-but-quantum May 15, 2024
39a5997
Fix warning: moving a temporary object prevents copy elision
mlxd May 15, 2024
7207a34
Ensure kokkos_swap used throughout
mlxd May 15, 2024
5d03538
Merge branch 'update/kokkos_version' of github.com:PennyLaneAI/pennyl…
mlxd May 15, 2024
37aa9eb
Auto update version from '0.37.0-dev13' to '0.37.0-dev14'
ringo-but-quantum May 15, 2024
61605de
Merge branch 'master' into update/kokkos_version
mlxd May 15, 2024
7dd8d43
Fix cuda kernels
vincentmr May 16, 2024
cbefdc4
Fix format.
vincentmr May 16, 2024
b35a054
Do not use maybe_unused in kokkos lambdas.
vincentmr May 16, 2024
5109093
Update LKokkos images.
vincentmr May 16, 2024
98523c2
Auto update version from '0.37.0-dev13' to '0.37.0-dev14'
ringo-but-quantum May 16, 2024
b08c356
Merge branch 'master' into update/dockerfile
vincentmr May 16, 2024
1875248
Merge remote-tracking branch 'origin/master' into bugfix_lk_cuda_kernels
vincentmr May 27, 2024
4ea7bc4
Auto update version from '0.37.0-dev18' to '0.37.0-dev19'
ringo-but-quantum May 27, 2024
f9cc0d6
Do not pipe errors to /dev/null
vincentmr May 27, 2024
12bfca9
Merge remote-tracking branch 'origin/bugfix_lk_cuda_kernels' into upd…
vincentmr May 27, 2024
1a522c5
Do not use [[maybe_unused]] in Kokkos kernel lambda signatures.
vincentmr May 27, 2024
ec0fca9
Merge remote-tracking branch 'origin/master' into update/dockerfile
vincentmr May 27, 2024
fa40378
Auto update version from '0.37.0-dev19' to '0.37.0-dev20'
ringo-but-quantum May 27, 2024
0f740b5
Apply suggestions from code review
vincentmr Jun 20, 2024
b67be9f
Merge branch 'master' into update/dockerfile
vincentmr Jun 20, 2024
268aaed
Auto update version from '0.37.0-dev44' to '0.37.0-dev45'
ringo-but-quantum Jun 20, 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
4 changes: 2 additions & 2 deletions .github/workflows/docker_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
lightning-version:
type: string
required: true
description: The version of Lightning to use. This should be a valid semantic version, e.g. 0.34.0.
description: The version of Lightning to use. This should be a valid git tag, e.g. v0.36.0.
push-to-dockerhub:
type: boolean
required: true
Expand All @@ -22,7 +22,7 @@ on:
lightning-version:
type: string
required: true
description: The version of Lightning to use. This should be a valid semantic version, e.g. 0.34.0.
description: The version of Lightning to use. This should be a valid git tag, e.g. v0.36.0.
push-to-dockerhub:
type: boolean
required: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ endif
ifdef version
VERSION := $(version)
else
VERSION := v0.35.0
VERSION := v0.36.0
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
endif

docker-build:
Expand Down
123 changes: 28 additions & 95 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
# Define build arguments
# Create and activate runtime virtual environment
FROM ubuntu:jammy AS base-runtime
ARG AMD_ARCH=AMD_GFX90A
ARG CUDA_ARCH=AMPERE80
ARG AMD_ARCH=AMD_GFX90A
ARG CUDA_INSTALLER=https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
ARG DEBIAN_FRONTEND=noninteractive
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
ARG GCC_VERSION=11
ARG KOKKOS_VERSION=4.3.01
ARG LIGHTNING_VERSION=v0.36.0
jay-selby marked this conversation as resolved.
Show resolved Hide resolved
ARG ROCM_INSTALLER=https://repo.radeon.com/amdgpu-install/5.7/ubuntu/jammy/amdgpu-install_5.7.50700-1_all.deb
ARG PENNYLANE_VERSION=v0.36.0
ARG ROCM_INSTALLER=https://repo.radeon.com/amdgpu-install/6.1.1/ubuntu/jammy/amdgpu-install_6.1.60101-1_all.deb
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
apt-utils \
ca-certificates \
git \
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
libgomp1 \
python3 \
python3-pip \
Expand All @@ -47,7 +49,6 @@ RUN apt-get update \
ccache \
cmake \
curl \
git \
ninja-build \
python3-dev \
gcc-${GCC_VERSION} g++-${GCC_VERSION} cpp-${GCC_VERSION} \
Expand All @@ -70,9 +71,7 @@ RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN rm -rf tmp && git clone --depth 1 --branch ${LIGHTNING_VERSION} https://github.com/PennyLaneAI/pennylane-lightning.git tmp\
&& mv tmp/* /opt/pennylane-lightning && rm -rf tmp
RUN pip install --no-cache-dir wheel
RUN pip install --no-cache-dir -r requirements-dev.txt
RUN pip install --no-cache-dir -r doc/requirements.txt
RUN pip install --no-cache-dir cmake ninja pybind11 wheel
maliasadi marked this conversation as resolved.
Show resolved Hide resolved

# Download Lightning release and build lightning-qubit backend
FROM base-build-python AS build-wheel-lightning-qubit
Expand All @@ -85,44 +84,22 @@ RUN python setup.py bdist_wheel
FROM base-runtime AS wheel-lightning-qubit
COPY --from=build-wheel-lightning-qubit /opt/pennylane-lightning/dist/ /
RUN pip install --force-reinstall --no-cache-dir PennyLane_Lightning*.whl && rm PennyLane_Lightning*.whl
RUN pip install --no-cache-dir -U pennylane

# Download Kokkos release and build OpenMP backend
FROM base-build as build-kokkos-openmp
WORKDIR /opt/kokkos-${KOKKOS_VERSION}
RUN wget --progress=dot:giga https://github.com/kokkos/kokkos/archive/refs/tags/${KOKKOS_VERSION}.tar.gz
RUN tar -zxf ${KOKKOS_VERSION}.tar.gz && mv /opt/kokkos-${KOKKOS_VERSION}/kokkos-${KOKKOS_VERSION}/* /opt/kokkos-${KOKKOS_VERSION}
RUN cmake -S /opt/kokkos-${KOKKOS_VERSION} -B /opt/kokkos-${KOKKOS_VERSION}/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/kokkos \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=OFF \
-DKokkos_ENABLE_SERIAL:BOOL=ON \
-DKokkos_ENABLE_OPENMP:BOOL=ON \
-DCMAKE_CXX_STANDARD=20 \
-DKokkos_ENABLE_EXAMPLES:BOOL=OFF \
-DKokkos_ENABLE_TESTS:BOOL=OFF \
-DKokkos_ENABLE_LIBDL:BOOL=OFF
RUN cmake --build /opt/kokkos-${KOKKOS_VERSION}/build
RUN cmake --install /opt/kokkos-${KOKKOS_VERSION}/build
RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@${PENNYLANE_VERSION}
maliasadi marked this conversation as resolved.
Show resolved Hide resolved

# Download Lightning release and build lightning-kokkos backend with Kokkos-OpenMP
FROM base-build-python AS build-wheel-lightning-kokkos-openmp
WORKDIR /opt/pennylane-lightning
COPY --from=build-kokkos-openmp /opt/kokkos /opt/kokkos
ENV CMAKE_PREFIX_PATH=/opt/kokkos:$CMAKE_PREFIX_PATH
ENV PL_BACKEND=lightning_kokkos
RUN pip uninstall -y pennylane-lightning
RUN PL_BACKEND=lightning_kokkos python setup.py build_ext
RUN PL_BACKEND=lightning_kokkos python setup.py bdist_wheel
RUN python setup.py build_ext -i --define="PL_BACKEND=lightning_kokkos;Kokkos_ENABLE_SERIAL:BOOL=ON;Kokkos_ENABLE_OPENMP:BOOL=ON"
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
RUN python setup.py bdist_wheel

# Install lightning-kokkos OpenMP backend
FROM base-runtime AS wheel-lightning-kokkos-openmp
COPY --from=build-kokkos-openmp /opt/kokkos /opt/kokkos
COPY --from=build-wheel-lightning-kokkos-openmp /opt/pennylane-lightning/dist/ /
COPY --from=build-wheel-lightning-qubit /opt/pennylane-lightning/dist/ /
RUN pip install --force-reinstall --no-cache-dir PennyLane_Lightning*.whl && rm PennyLane_Lightning*.whl
RUN pip install --no-cache-dir -U pennylane
RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@${PENNYLANE_VERSION}

# Install CUDA-12 in build venv image
FROM base-build-python as base-build-cuda
Expand All @@ -133,45 +110,23 @@ RUN ./cuda-install.run --silent --toolkit --toolkitpath=/usr/local/cuda-$(echo $
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}

# Download Kokkos release and build CUDA backend
FROM base-build-cuda as build-kokkos-cuda
WORKDIR /opt/kokkos-${KOKKOS_VERSION}
# RUN wget --progress=dot:giga https://github.com/kokkos/kokkos/archive/refs/tags/${KOKKOS_VERSION}.tar.gz
# RUN tar -zxf ${KOKKOS_VERSION}.tar.gz && mv /opt/kokkos-${KOKKOS_VERSION}/kokkos-${KOKKOS_VERSION}/* /opt/kokkos-${KOKKOS_VERSION}
RUN git clone --branch lightning https://github.com/vincentmr/kokkos.git /opt/kokkos-${KOKKOS_VERSION}
RUN cmake -S /opt/kokkos-${KOKKOS_VERSION} -B /opt/kokkos-${KOKKOS_VERSION}/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/kokkos \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=OFF \
-DKokkos_ENABLE_SERIAL:BOOL=ON \
-DKokkos_ENABLE_OPENMP:BOOL=ON \
-DCMAKE_CXX_STANDARD=20 \
-DKokkos_ENABLE_EXAMPLES:BOOL=OFF \
-DKokkos_ENABLE_TESTS:BOOL=OFF \
-DKokkos_ENABLE_LIBDL:BOOL=OFF \
-DKokkos_ENABLE_CUDA:BOOL=ON \
-DKokkos_ARCH_${CUDA_ARCH}=ON
RUN cmake --build /opt/kokkos-${KOKKOS_VERSION}/build
RUN cmake --install /opt/kokkos-${KOKKOS_VERSION}/build

# Download Lightning release and build lightning-kokkos backend with Kokkos-CUDA
FROM base-build-cuda AS build-wheel-lightning-kokkos-cuda
WORKDIR /opt/pennylane-lightning
COPY --from=build-kokkos-cuda /opt/kokkos /opt/kokkos
ENV CMAKE_PREFIX_PATH=/opt/kokkos:$CMAKE_PREFIX_PATH
ENV PL_BACKEND=lightning_kokkos
RUN pip uninstall -y pennylane-lightning
RUN echo >> cmake/support_kokkos.cmake && echo "find_package(CUDAToolkit REQUIRED)" >> cmake/support_kokkos.cmake
RUN PL_BACKEND=lightning_kokkos python setup.py build_ext
RUN PL_BACKEND=lightning_kokkos python setup.py bdist_wheel
RUN python setup.py build_ext -i --define="PL_BACKEND=lightning_kokkos;Kokkos_ENABLE_SERIAL:BOOL=ON;Kokkos_ENABLE_OPENMP:BOOL=ON;Kokkos_ENABLE_CUDA:BOOL=ON;Kokkos_ARCH_${CUDA_ARCH}=ON"
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
RUN python setup.py bdist_wheel

# Install python3 and setup runtime virtual env in CUDA-12-runtime image (includes CUDA runtime and math libraries)
# Install lightning-kokkos CUDA backend
FROM nvidia/cuda:12.2.0-base-ubuntu22.04 AS wheel-lightning-kokkos-cuda
ARG PENNYLANE_VERSION=v0.36.0
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libgomp1 \
git \
python3 \
python3-pip \
python3-venv \
Expand All @@ -180,25 +135,26 @@ RUN apt-get update \
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=build-kokkos-cuda /opt/kokkos /opt/kokkos
COPY --from=build-wheel-lightning-kokkos-cuda /opt/pennylane-lightning/dist/ /
COPY --from=build-wheel-lightning-qubit /opt/pennylane-lightning/dist/ /
RUN pip install --force-reinstall --no-cache-dir PennyLane_Lightning*.whl && rm PennyLane_Lightning*.whl
RUN pip install --no-cache-dir -U pennylane
RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@${PENNYLANE_VERSION}

# Download and build Lightning-GPU release
FROM base-build-cuda AS build-wheel-lightning-gpu
WORKDIR /opt/pennylane-lightning
RUN pip install --no-cache-dir wheel custatevec-cu12
RUN pip uninstall -y pennylane-lightning
RUN CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") PL_BACKEND=lightning_gpu python setup.py build_ext
RUN PL_BACKEND=lightning_gpu python setup.py bdist_wheel
RUN python setup.py bdist_wheel

# Install python3 and setup runtime virtual env in CUDA-12-runtime image (includes CUDA runtime and math libraries)
# Install lightning-kokkos CUDA backend
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 AS wheel-lightning-gpu
ARG PENNYLANE_VERSION=v0.36.0
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
git \
libgomp1 \
python3 \
python3-pip \
Expand All @@ -213,7 +169,7 @@ ENV LD_LIBRARY_PATH="$VIRTUAL_ENV/lib/python3.10/site-packages/cuquantum/lib:$LD
COPY --from=build-wheel-lightning-gpu /opt/pennylane-lightning/dist/ /
COPY --from=build-wheel-lightning-qubit /opt/pennylane-lightning/dist/ /
RUN pip install --no-cache-dir --force-reinstall PennyLane_Lightning*.whl && rm PennyLane_Lightning*.whl
RUN pip install --no-cache-dir -U pennylane
RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@${PENNYLANE_VERSION}

# Install ROCm in build venv image
FROM base-build-python as base-build-rocm
Expand All @@ -226,44 +182,22 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
RUN amdgpu-install -y --accept-eula --usecase=rocm,hiplibsdk --no-dkms

# Download Kokkos release and build HIP backend
FROM base-build-rocm as build-kokkos-rocm
WORKDIR /opt/kokkos-${KOKKOS_VERSION}
ENV LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
# RUN wget --progress=dot:giga https://github.com/kokkos/kokkos/archive/refs/tags/${KOKKOS_VERSION}.tar.gz
# RUN tar -zxf ${KOKKOS_VERSION}.tar.gz && mv /opt/kokkos-${KOKKOS_VERSION}/kokkos-${KOKKOS_VERSION}/* /opt/kokkos-${KOKKOS_VERSION}
RUN git clone --branch fix-rtld-deepbind https://github.com/cz4rs/kokkos.git /opt/kokkos-${KOKKOS_VERSION}
RUN CXX=hipcc cmake -S /opt/kokkos-${KOKKOS_VERSION} -B /opt/kokkos-${KOKKOS_VERSION}/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/kokkos \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=OFF \
-DKokkos_ENABLE_SERIAL:BOOL=ON \
-DKokkos_ENABLE_OPENMP:BOOL=ON \
-DCMAKE_CXX_STANDARD=20 \
-DKokkos_ENABLE_EXAMPLES:BOOL=OFF \
-DKokkos_ENABLE_TESTS:BOOL=OFF \
-DKokkos_ENABLE_LIBDL:BOOL=OFF \
-DKokkos_ENABLE_HIP:BOOL=ON \
-DKokkos_ARCH_${AMD_ARCH}=ON
RUN cmake --build /opt/kokkos-${KOKKOS_VERSION}/build
RUN cmake --install /opt/kokkos-${KOKKOS_VERSION}/build

# Download Lightning release and build lightning-kokkos backend with Kokkos-ROCm
FROM base-build-rocm AS build-wheel-lightning-kokkos-rocm
WORKDIR /opt/pennylane-lightning
COPY --from=build-kokkos-rocm /opt/kokkos /opt/kokkos
ENV CMAKE_PREFIX_PATH=/opt/rocm:$CMAKE_PREFIX_PATH
ENV CXX=hipcc
ENV CMAKE_PREFIX_PATH=/opt/kokkos:$CMAKE_PREFIX_PATH
ENV PL_BACKEND=lightning_kokkos
RUN pip uninstall -y pennylane-lightning
RUN PL_BACKEND=lightning_kokkos python setup.py build_ext
RUN PL_BACKEND=lightning_kokkos python setup.py bdist_wheel
RUN python setup.py build_ext -i --define="PL_BACKEND=lightning_kokkos;Kokkos_ENABLE_SERIAL:BOOL=ON;Kokkos_ENABLE_OPENMP:BOOL=ON;Kokkos_ENABLE_HIP:BOOL=ON;Kokkos_ARCH_${AMD_ARCH}=ON"
RUN python setup.py bdist_wheel

# Install lightning-kokkos HIP backend
FROM rocm/dev-ubuntu-22.04:5.7 AS wheel-lightning-kokkos-rocm
ARG PENNYLANE_VERSION=v0.36.0
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
git \
libgomp1 \
python3 \
python3-pip \
Expand All @@ -273,8 +207,7 @@ RUN apt-get update \
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=build-kokkos-rocm /opt/kokkos /opt/kokkos
COPY --from=build-wheel-lightning-kokkos-rocm /opt/pennylane-lightning/dist/ /
COPY --from=build-wheel-lightning-qubit /opt/pennylane-lightning/dist/ /
RUN pip install --force-reinstall --no-cache-dir PennyLane_Lightning*.whl && rm PennyLane_Lightning*.whl
RUN pip install --no-cache-dir -U pennylane
RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@${PENNYLANE_VERSION}
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.37.0-dev19"
__version__ = "0.37.0-dev20"
Loading
Loading