Skip to content

Instantly share code, notes, and snippets.

@splch
Last active May 3, 2023 22:38
Show Gist options
  • Save splch/16c6d46983a88505f73c6d6363d6e218 to your computer and use it in GitHub Desktop.
Save splch/16c6d46983a88505f73c6d6363d6e218 to your computer and use it in GitHub Desktop.
# Start with a base Ubuntu 22.04 image
# --platform=linux/amd64
FROM ubuntu:22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
LLVM_VERSION=c0b45fef155fbe3f17f9a6f99074682c69545488 \
LLVM_INSTALL_PATH=/opt/llvm \
CUDAQ_INSTALL_PATH=$HOME/.cudaq
# Install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc g++ \
git \
cmake \
ninja-build \
python3 \
python3-pip \
python3-dev \
wget \
libblas-dev \
liblapack-dev && \
rm -rf /var/lib/apt/lists/*
# Build LLVM / Clang / MLIR
RUN mkdir llvm-project && \
cd llvm-project && \
git init && \
git remote add origin https://github.com/llvm/llvm-project && \
git fetch origin --depth=1 ${LLVM_VERSION} && \
git reset --hard FETCH_HEAD && \
mkdir build && \
cd build && \
cmake ../llvm -G Ninja \
-DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_INSTALL_PREFIX=${LLVM_INSTALL_PATH} \
-DLLVM_ENABLE_PROJECTS="clang;mlir" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_INSTALL_UTILS=TRUE && \
ninja install && \
cp bin/llvm-lit ${LLVM_INSTALL_PATH}/bin/
RUN pip3 install lit numpy pytest
# Build CUDA Quantum
RUN git clone https://github.com/NVIDIA/cuda-quantum && \
cd cuda-quantum && \
mkdir build && \
cd build && \
cmake .. -G Ninja \
-DCMAKE_INSTALL_PREFIX=${CUDAQ_INSTALL_PATH} \
-DLLVM_DIR=${LLVM_INSTALL_PATH}/lib/cmake/llvm \
-DCUDAQ_ENABLE_PYTHON=TRUE && \
ninja install && \
ctest -E ctest-nvqpp
# Set the working directory
WORKDIR /workspace
# Entry point
CMD ["/bin/bash"]
@splch
Copy link
Author

splch commented May 3, 2023

# enable docker build to use >4g of memory
docker build -t ghcr.io/nvidia/cuda-quantum:latest -f docker/build/cudaq.Dockerfile . && docker run -it --rm ghcr.io/nvidia/cuda-quantum:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment