From 946de08c6262515825fd35f6dfa84add618ca8ef Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Fri, 11 Apr 2025 17:02:52 -0400 Subject: [PATCH 1/7] Add Docker scripts for building ArrayFire 3.10 release. --- Dockerfile | 80 ----------- README | 9 ++ README.md | 51 ------- arrayfire/manylinux/cuda_deps/Dockerfile | 20 +++ arrayfire/manylinux/dependencies/Dockerfile | 41 ++++++ arrayfire/manylinux/dev_base/Dockerfile | 23 +++ arrayfire/scripts/build_arrayfire.sh | 150 ++++++++++++++++++++ arrayfire/ubuntu/cuda_deps/Dockerfile | 20 +++ arrayfire/ubuntu/dependencies/Dockerfile | 26 ++++ arrayfire/ubuntu/dev_base/Dockerfile | 32 +++++ docker-compose.yml | 95 +++++++++++++ test_dockers/STGZ/Dockerfile | 20 +++ 12 files changed, 436 insertions(+), 131 deletions(-) delete mode 100644 Dockerfile create mode 100644 README delete mode 100644 README.md create mode 100644 arrayfire/manylinux/cuda_deps/Dockerfile create mode 100644 arrayfire/manylinux/dependencies/Dockerfile create mode 100644 arrayfire/manylinux/dev_base/Dockerfile create mode 100755 arrayfire/scripts/build_arrayfire.sh create mode 100644 arrayfire/ubuntu/cuda_deps/Dockerfile create mode 100644 arrayfire/ubuntu/dependencies/Dockerfile create mode 100644 arrayfire/ubuntu/dev_base/Dockerfile create mode 100644 docker-compose.yml create mode 100644 test_dockers/STGZ/Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 15a004e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,80 +0,0 @@ -FROM nvidia/cuda:11.4.2-devel-ubuntu20.04 -MAINTAINER support@arrayfire.com - -ENV DEBIAN_FRONTEND=nonintercative - -RUN apt-get update && apt-get install -y software-properties-common && \ - apt-get install -y --no-install-recommends \ - build-essential \ - clinfo \ - cmake \ - git \ - libboost-all-dev \ - libfftw3-dev \ - libfontconfig1-dev \ - libfreeimage-dev \ - liblapack-dev \ - liblapacke-dev \ - libopenblas-dev \ - ocl-icd-opencl-dev \ - opencl-headers \ - wget \ - xorg-dev && \ - rm -rf /var/lib/apt/lists/* - -# Setting up symlinks for libcuda and OpenCL ICD -RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/lib/libcuda.so.1 && \ - ln -s /usr/lib/libcuda.so.1 /usr/lib/libcuda.so && \ - mkdir -p /etc/OpenCL/vendors && \ - echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd && \ - echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \ - echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf -ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} - -WORKDIR /root - -# Build GLFW from source -RUN git clone --depth 1 --branch 3.3.4 https://github.com/glfw/glfw.git && \ - cd glfw && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=/usr .. && \ - make -j4 && \ - make install - -RUN cd /tmp && \ - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \ - apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \ - rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \ - echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list && \ - add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" && \ - apt update -y && apt install -y intel-basekit - -SHELL ["/bin/bash", "-c"] - -# AF_DISABLE_GRAPHICS - Environment variable to disable graphics at -# runtime due to lack of graphics support by docker - visit -# http://arrayfire.org/docs/configuring_environment.htm#af_disable_graphics -# for more information -ENV AF_PATH=/opt/arrayfire AF_DISABLE_GRAPHICS=1 -ARG COMPILE_GRAPHICS=OFF -RUN source /opt/intel/oneapi/setvars.sh && \ - git clone --depth 1 --recursive https://github.com/arrayfire/arrayfire.git -b master && \ - cd arrayfire && mkdir build && cd build && \ - cmake .. -DCMAKE_INSTALL_PREFIX=/opt/arrayfire-3 \ - -DCMAKE_BUILD_TYPE=Release \ - -DAF_BUILD_CPU=ON \ - -DAF_BUILD_CUDA=ON \ - -DAF_BUILD_DOCS=OFF \ - -DAF_BUILD_EXAMPLES=ON \ - -DAF_BUILD_OPENCL=ON \ - -DAF_BUILD_UNIFIED=ON \ - -DAF_WITH_FREEIMAGE_STATIC=OFF && \ - # -DCOMPUTES_DETECTED_LIST="30;35;37;50;52;60" \ - make -j8 && make install && \ - mkdir -p ${AF_PATH} && ln -s /opt/arrayfire-3/* ${AF_PATH}/ && \ - echo "${AF_PATH}/lib" >> /etc/ld.so.conf.d/arrayfire.conf && \ - echo "/usr/local/cuda/nvvm/lib64" >> /etc/ld.so.conf.d/arrayfire.conf && \ - ldconfig - -WORKDIR /root/arrayfire diff --git a/README b/README new file mode 100644 index 0000000..d27fe16 --- /dev/null +++ b/README @@ -0,0 +1,9 @@ +Builders are defined in the docker-compose.yml file. + +To run a particular build, do: docker-compose up + +The build script used is: arrayfire/scripts/build_arrayfire.sh + +A directory will be created here with the build files with the form: build__arrayfire__ + +The installer can be tested by copying the installer package to the test docker in test_dockers and building (note for the CUDA back end you will need an Nvidia GPU and the CUDA docker toolkit installed). diff --git a/README.md b/README.md deleted file mode 100644 index dc1adf3..0000000 --- a/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# arrayfire-docker - -Dockerfile for Building and Using ArrayFire https://github.com/arrayfire/arrayfire.git - -## Dependencies - -[nvidia-docker](https://github.com/NVIDIA/nvidia-docker) - -## Building image - -``` -nvidia-docker build -t arrayfire . -``` - -Make sure to modify ArrayFire's -[build arguments](https://github.com/arrayfire/arrayfire-docker/blob/master/Dockerfile#L43) -in the `Dockerfile` to suit your needs prior to building the image. - -## Running container - -``` -nvidia-docker run --rm -ti arrayfire -``` - -Once running, invoke the -[unified backend](http://arrayfire.org/docs/unifiedbackend.htm) test to show -available devices for each of ArrayFire's backends: - -``` -./build/test/backend_unified -``` - -## Compiling stand-alone examples - -``` -cp -R /opt/arrayfire/share/ArrayFire/examples /root/arrayfire-examples -cd /root/arrayfire-examples && mkdir build && cd build -cmake .. -DArrayFire_DIR=/opt/arrayfire/share/ArrayFire/cmake -make -j8 -``` - -Take a look at the examples -[`README.md`](https://github.com/arrayfire/arrayfire/blob/devel/examples/README.md) -for more information. - -### Support and Contact Info - -* Google Groups: https://groups.google.com/forum/#!forum/arrayfire-users -* ArrayFire Services: [Consulting](http://arrayfire.com/consulting/) | [Support](http://arrayfire.com/support/) | [Training](http://arrayfire.com/training/) -* ArrayFire Blogs: http://arrayfire.com/blog/ -* Email: diff --git a/arrayfire/manylinux/cuda_deps/Dockerfile b/arrayfire/manylinux/cuda_deps/Dockerfile new file mode 100644 index 0000000..bb329d9 --- /dev/null +++ b/arrayfire/manylinux/cuda_deps/Dockerfile @@ -0,0 +1,20 @@ +FROM af/manylinux/dependencies +MAINTAINER Christophe Murphy + +ARG AF_CUDA_VERSION + +RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && \ + dnf clean all && \ + dnf -y install cuda-toolkit-${AF_CUDA_VERSION} && \ + dnf -y install cudnn-cuda-${AF_CUDA_VERSION} && \ + dnf clean all + +# Create Nvidia's ICD and missing standard simlinks for the CUDA driver and OpenCL +RUN mkdir -p /etc/OpenCL/vendors && \ + echo "/usr/local/cuda/targets/x86_64-linux/lib/libOpenCL.so" > /etc/OpenCL/vendors/nvidia.icd && \ + ldconfig && \ + ln -s /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so \ + /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so.1 + +ENV PATH /usr/local/cuda/bin:${PATH} +ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:${LD_LIBRARY_PATH} diff --git a/arrayfire/manylinux/dependencies/Dockerfile b/arrayfire/manylinux/dependencies/Dockerfile new file mode 100644 index 0000000..8e79498 --- /dev/null +++ b/arrayfire/manylinux/dependencies/Dockerfile @@ -0,0 +1,41 @@ +FROM af/manylinux/dev_base +MAINTAINER Christophe Murphy + +# Boost +FROM af/manylinux/dev_base as boost +RUN cd /usr/src && \ + wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \ + tar -xvzf boost_1_87_0.tar.gz && \ + cd boost_1_87_0 && \ + ./bootstrap.sh --prefix=/artifact && \ + ./b2 install && \ + cd /usr/src && rm -rf boost_1_87_0* + +# Doxygen +FROM af/manylinux/dev_base as doxygen +RUN cd /usr/src && \ + git clone -b Release_1_13_2 https://github.com/doxygen/doxygen.git && \ + cd doxygen && \ + mkdir build && cd build && \ + cmake -DCMAKE_INSTALL_PREFIX:PATH=/artifact .. && \ + make -j$(grep -c processor /proc/cpuinfo) install && \ + cd /usr/src && rm -rf doxygen + +FROM af/manylinux/dev_base +MAINTAINER Christophe Murphy + +# Boost +COPY --from=boost /artifact /usr +# Doxgyen +COPY --from=doxygen /artifact /usr + +# oneAPI +RUN echo $'[oneAPI]\n\ +name=IntelĀ® oneAPI repository\n\ +baseurl=https://yum.repos.intel.com/oneapi\n\ +enabled=1\n\ +gpgcheck=1\n\ +repo_gpgcheck=1\n\ +gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB' > /etc/yum.repos.d/oneAPI.repo && \ +cat /etc/yum.repos.d/oneAPI.repo && \ +dnf -y update && dnf -y install intel-oneapi-base-toolkit && dnf clean all diff --git a/arrayfire/manylinux/dev_base/Dockerfile b/arrayfire/manylinux/dev_base/Dockerfile new file mode 100644 index 0000000..a3fab21 --- /dev/null +++ b/arrayfire/manylinux/dev_base/Dockerfile @@ -0,0 +1,23 @@ +FROM quay.io/pypa/manylinux_2_28_x86_64 +MAINTAINER Christophe Murphy +RUN dnf update -y && \ + dnf groupinstall -y "Development Tools" && \ + dnf -y install ocl-icd ocl-icd-devel opencl-headers \ + wget freetype-devel fontconfig-devel \ + fftw-devel openblas-devel lapack-devel \ + glfw-devel graphviz graphviz-devel \ + mesa-libGLU-devel freeimage-devel && \ + dnf clean all + +# Set location for OpenCL library +ENV OCL_ROOT /usr +ENV OPENCL_ROOT /usr + +# Ninja build system +RUN cd /usr/src && \ + git clone https://github.com/ninja-build/ninja.git && \ + cd ninja && \ + git checkout v1.12.1 && \ + ./configure.py --bootstrap && \ + mv ninja /usr/bin/ && \ + cd .. && rm -rf ninja diff --git a/arrayfire/scripts/build_arrayfire.sh b/arrayfire/scripts/build_arrayfire.sh new file mode 100755 index 0000000..ec30bc5 --- /dev/null +++ b/arrayfire/scripts/build_arrayfire.sh @@ -0,0 +1,150 @@ +#!/bin/bash +set -e +set -x + +use_oneapi=ON +with_graphics=ON +build_cpu=ON +build_cuda=ON +build_oneapi=ON +build_opencl=ON +build_type="RelWithDebInfo" +compute_library_cmake_flag="-DAF_COMPUTE_LIBRARY=Intel-MKL" + +distro=$(paste -d "_" <(cat /etc/*release | grep "^NAME=" | head -n 1 | cut -d '"' -f 2) <(cat /etc/*release | grep "^VERSION_ID=" | head -n 1 | cut -d '"' -f 2)) +build_dir=build_$distro + +AF_CUDA_arch_build_targets="5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX" + +LONGOPTIONS=no-gl,build-type:,no-mkl,no-cpu,no-cuda,no-oneapi,no-opencl,package-type:,cuda-arch: +PARSED=$(getopt --options="" --longoptions=$LONGOPTIONS --name "$0" -- "$@") +if [[ $? -ne 0 ]]; then + # e.g. $? == 1 + # then getopt has complained about wrong arguments to stdout + exit 2 +fi + +eval set -- "$PARSED" + +while true; do + case "$1" in + --no-gl) + with_graphics=OFF + shift + ;; + --build-type) + build_type="$2" + shift 2 + ;; + --no-mkl) + use_oneapi=OFF + build_oneapi=OFF + compute_library_cmake_flag="-DAF_COMPUTE_LIBRARY=FFTW/LAPACK/BLAS -DBLA_VENDOR=OpenBLAS" + shift + ;; + --no-cpu) + build_cpu=OFF + shift + ;; + --no-cuda) + build_cuda=OFF + shift + ;; + --no-oneapi) + build_oneapi=OFF + shift + ;; + --no-opencl) + build_opencl=OFF + shift + ;; + --package-type) + package_type="$2" + shift 2 + ;; + --cuda-arch) + AF_CUDA_arch_build_targets="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + echo "Programming error" + exit 3 + ;; + esac +done + +cd /usr/src + +if [[ ! -d arrayfire/ ]]; then + git clone --recursive https://github.com/arrayfire/arrayfire + cd arrayfire + git config user.email "installer@docker.xyz" + git config user.name "Installer Builder" + git merge -m "add_mkl_install_libs" origin/add_mkl_install_libs + git merge -m "allow_minor_ver_compat" origin/allow_minor_ver_compat + git merge -m "update_af_deps" origin/update_af_deps +else + cd arrayfire + git pull +fi + +mkdir -p "$build_dir" +cd "$build_dir" + +if [ "$use_oneapi" = "ON" ]; then + set +x + source /opt/intel/oneapi/setvars.sh + set -x + # Additional libraries are not needed because they are provided by the runtime + #compute_library_cmake_flag+=" -DAF_ADDITIONAL_MKL_LIBRARIES:FILEPATHS=`find $TBBROOT -name libtbb.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libintlc.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libsycl.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libur_loader.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`" +fi + +# Look for correct OpenCL library and headers, location depends on the distro +for ocl in "/usr/lib64/libOpenCL.so.1" "/usr/lib/x86_64-linux-gnu/libOpenCL.so.1"; do + if [ -f "$ocl" ]; then ocl_dir=$ocl; break; fi +done +if [ -z "$ocl_dir" ]; then + echo "Couldn't find OpenCL library!" + exit 1 +else + opencl_library_cmake_flag=" -DOpenCL_LIBRARY=$ocl_dir -DOPENCL_LIBRARIES=$ocl_dir" +fi +opencl_include_cmake_flag=" -DOPENCL_INCLUDE_DIRS=${OCL_ROOT}/include -DOpenCL_INCLUDE_DIR=${OCL_ROOT}/include" + +cmake -G Ninja \ + -DCMAKE_BUILD_TYPE:STRING="$build_type" \ + -DFG_USE_STATIC_CPPFLAGS:BOOL=OFF \ + -DAF_WITH_STATIC_CUDA_NUMERIC_LIBS=OFF \ + -DFG_WITH_FREEIMAGE:BOOL=ON \ + $compute_library_cmake_flag \ + -DAF_BUILD_CPU:BOOL="$build_cpu" \ + -DAF_BUILD_DOCS:BOOL=ON \ + -DAF_BUILD_EXAMPLES:BOOL=OFF \ + -DAF_BUILD_ONEAPI:BOOL="$build_oneapi" \ + -DAF_BUILD_CUDA:BOOL="$build_cuda" \ + -DAF_BUILD_OPENCL:BOOL="$build_opencl" \ + -DAF_BUILD_FORGE:BOOL=$with_graphics \ + -DCMAKE_SYCL_COMPILER=icpx \ + -DCMAKE_SYCL_FLAGS="-fsycl -D_GLIBCXX_USE_CXX11_ABI=1" \ + -DAF_WITH_IMAGEIO:BOOL=ON \ + -DAF_WITH_LOGGING:BOOL=ON \ + -DAF_INSTALL_STANDALONE:BOOL=ON \ + -DAF_WITH_SPDLOG_HEADER_ONLY=ON \ + -DAF_WITH_FMT_HEADER_ONLY=ON \ + -DBUILD_TESTING:BOOL=OFF \ + -DCUDA_architecture_build_targets:STRING=$AF_CUDA_arch_build_targets \ + $opencl_library_cmake_flag \ + $opencl_include_cmake_flag \ + .. + +# This may need to be adjusted depending on how much memory your system has. +# oneAPI backend compilation uses a lot. +#cmake --build . -- -v +cmake --build . -j 4 -- -v + +cpack -G "$package_type" + diff --git a/arrayfire/ubuntu/cuda_deps/Dockerfile b/arrayfire/ubuntu/cuda_deps/Dockerfile new file mode 100644 index 0000000..564fe3d --- /dev/null +++ b/arrayfire/ubuntu/cuda_deps/Dockerfile @@ -0,0 +1,20 @@ +FROM af/ubuntu/dependencies +MAINTAINER Christophe Murphy + +ARG AF_CUDA_VERSION + +RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ + dpkg -i cuda-keyring_1.1-1_all.deb && apt-get update -y && \ + apt-get -y install cuda-toolkit-${AF_CUDA_VERSION} && \ + apt-get -y install cudnn9-cuda-${AF_CUDA_VERSION} && \ + apt-get clean -y && rm -rf cuda-keyring_1.1-1_all.deb + +# Create Nvidia's ICD and missing standard simlink for CUDA stub library +RUN mkdir -p /etc/OpenCL/vendors && \ + echo "/usr/local/cuda/targets/x86_64-linux/lib/libOpenCL.so" > /etc/OpenCL/vendors/nvidia.icd && \ + ldconfig && \ + ln -s /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so \ + /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so.1 + +ENV PATH /usr/local/cuda/bin:${PATH} +ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:${LD_LIBRARY_PATH} diff --git a/arrayfire/ubuntu/dependencies/Dockerfile b/arrayfire/ubuntu/dependencies/Dockerfile new file mode 100644 index 0000000..6f3878f --- /dev/null +++ b/arrayfire/ubuntu/dependencies/Dockerfile @@ -0,0 +1,26 @@ +FROM af/ubuntu/dev_base +MAINTAINER Christophe Murphy + +RUN apt-get update -y + +# Boost +RUN apt-get install -y libboost-all-dev + +# Doxygen +RUN apt-get install -y graphviz libgraphviz-dev flex bison +RUN cd /usr/src && \ + git clone -b Release_1_13_2 https://github.com/doxygen/doxygen.git && \ + cd doxygen && \ + mkdir build && cd build && \ + cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && \ + make -j$(grep -c processor /proc/cpuinfo) install && \ + cd /usr/src && rm -rf doxygen + +# oneAPI +RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ + echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | tee /etc/apt/sources.list.d/oneAPI.list && \ + apt-get update -y && apt-get install -y intel-oneapi-base-toolkit + +RUN apt-get clean -y diff --git a/arrayfire/ubuntu/dev_base/Dockerfile b/arrayfire/ubuntu/dev_base/Dockerfile new file mode 100644 index 0000000..9206181 --- /dev/null +++ b/arrayfire/ubuntu/dev_base/Dockerfile @@ -0,0 +1,32 @@ +ARG UBUNTU_LTS_VERSION + +FROM ubuntu:$UBUNTU_LTS_VERSION +MAINTAINER Christophe Murphy +RUN apt-get update -y && \ + apt-get install -y wget build-essential git \ + libopenblas-dev libfftw3-dev \ + libfreetype-dev libfontconfig-dev \ + liblapacke-dev ocl-icd-opencl-dev \ + opencl-headers libglfw3-dev \ + libfreeimage-dev libglu1-mesa-dev + +# Set location for OpenCL library +ENV OCL_ROOT /usr + +# CMake +RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \ + | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null && \ + echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' \ + | tee /etc/apt/sources.list.d/kitware.list >/dev/null && \ + apt-get update -y && apt-get install -y cmake + +RUN apt-get clean -y + +# Ninja build system +RUN cd /usr/src && \ + git clone https://github.com/ninja-build/ninja.git && \ + cd ninja && \ + git checkout v1.12.1 && \ + ./configure.py --bootstrap && \ + mv ninja /usr/bin/ && \ + cd .. && rm -rf ninja diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..416884d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,95 @@ +version: "3.4" + +services: + af_manylinux_2_28_base: + build: + context: ./arrayfire/manylinux/dev_base + image: af/manylinux/dev_base + + af_manylinux_2_28_deps: + build: + context: ./arrayfire/manylinux/dependencies + image: af/manylinux/dependencies + depends_on: + - af_manylinux_2_28_base + + af_manylinux_2_28_cuda_12.8: + build: + context: ./arrayfire/manylinux/cuda_deps + args: + AF_CUDA_VERSION: 12-8 + image: af/manylinux/cuda:12.8 + depends_on: + - af_manylinux_2_28_deps + + af_manylinux_2_28_arrayfire_mkl: + image: af/manylinux/cuda:12.8 + depends_on: + - af_manylinux_2_28_cuda_12.8 + volumes: + - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts + - /home/arrayfire/build_dockers/build_manylinux_arrayfire_mkl_2025_cuda_12_8:/usr/src + stdin_open: true + tty: true + command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo + --package-type STGZ --cuda-arch \"5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX\"" + + af_manylinux_2_28_arrayfire_openblas: + image: af/manylinux/cuda:12.8 + depends_on: + - af_manylinux_2_28_cuda_12.8 + volumes: + - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts + - /home/arrayfire/build_dockers/build_manylinux_arrayfire_openblas_cuda_12_8:/usr/src + stdin_open: true + tty: true + command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo + --package-type STGZ --cuda-arch \"5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX\" --no-mkl" + + af_ubuntu_22_04_base: + build: + context: ./arrayfire/ubuntu/dev_base + args: + UBUNTU_LTS_VERSION: 22.04 + image: af/ubuntu/dev_base + + af_ubuntu_22_04_deps: + build: + context: ./arrayfire/ubuntu/dependencies + image: af/ubuntu/dependencies + depends_on: + - af_ubuntu_22_04_base + + af_ubuntu_22_04_cuda_12.8: + build: + context: ./arrayfire/ubuntu/cuda_deps + args: + AF_CUDA_VERSION: 12-8 + image: af/ubuntu/cuda:12.8 + depends_on: + - af_ubuntu_22_04_deps + + af_ubuntu_22_04_arryfire_mkl: + image: af/ubuntu/cuda:12.8 + depends_on: + - af_ubuntu_22_04_cuda_12.8 + volumes: + - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts + - /home/arrayfire/build_dockers/build_ubuntu_arrayfire_mkl_2025_cuda_12_8:/usr/src + stdin_open: true + tty: true + command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo + --package-type DEB --cuda-arch \"5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX\"" + + af_ubuntu_22_04_openblas_cuda_12.8: + image: af/ubuntu/cuda:12.8 + depends_on: + - af_ubuntu_22_04_cuda_12.8 + volumes: + - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts + - /home/arrayfire/build_dockers/build_ubuntu_arrayfire_openblas_cuda_12_8:/usr/src + stdin_open: true + tty: true + command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo + --package-type DEB --cuda-arch \"5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX\" --no-mkl" + diff --git a/test_dockers/STGZ/Dockerfile b/test_dockers/STGZ/Dockerfile new file mode 100644 index 0000000..180104f --- /dev/null +++ b/test_dockers/STGZ/Dockerfile @@ -0,0 +1,20 @@ +FROM nvidia/cuda:12.8.1-base-ubuntu22.04 + +RUN apt update && apt-get -y install nvidia-compute-utils-570 wget clinfo build-essential cmake + +RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ + echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list && \ + apt update && apt-get -y install intel-oneapi-runtime-opencl intel-oneapi-compiler-dpcpp-cpp-runtime + +COPY ArrayFire-3.10.0-Linux.sh /usr/src + +RUN cd /usr/src && ./ArrayFire-3.10.0-Linux.sh --skip-license && rm ArrayFire-3.10.0-Linux.sh + +RUN cd /usr/src/share/ArrayFire/examples && mkdir build && cd build && \ + . /opt/intel/oneapi/setvars.sh && \ + cmake -DArrayFire_DIR=/usr/src/share/ArrayFire/cmake .. && make -j 14 + +RUN echo '\n\ +# Source the runtime so we can run oneapi back end\n\ +. /opt/intel/oneapi/setvars.sh' >> /etc/bash.bashrc From 849f2061a6e0fad9e0a95b7ff164709cf9559a26 Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Fri, 11 Apr 2025 17:08:39 -0400 Subject: [PATCH 2/7] Remove already merged branch from script --- arrayfire/scripts/build_arrayfire.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/arrayfire/scripts/build_arrayfire.sh b/arrayfire/scripts/build_arrayfire.sh index ec30bc5..c247fed 100755 --- a/arrayfire/scripts/build_arrayfire.sh +++ b/arrayfire/scripts/build_arrayfire.sh @@ -85,7 +85,6 @@ if [[ ! -d arrayfire/ ]]; then git config user.email "installer@docker.xyz" git config user.name "Installer Builder" git merge -m "add_mkl_install_libs" origin/add_mkl_install_libs - git merge -m "allow_minor_ver_compat" origin/allow_minor_ver_compat git merge -m "update_af_deps" origin/update_af_deps else cd arrayfire From 9a499f4c495d63a5b40fa5d2d0b85f6ac4511781 Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Tue, 15 Apr 2025 13:47:54 -0700 Subject: [PATCH 3/7] Pre-package oneAPI libraries. --- arrayfire/scripts/build_arrayfire.sh | 17 +++++++++++++++-- test_dockers/STGZ/Dockerfile | 7 +------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arrayfire/scripts/build_arrayfire.sh b/arrayfire/scripts/build_arrayfire.sh index c247fed..c5891e6 100755 --- a/arrayfire/scripts/build_arrayfire.sh +++ b/arrayfire/scripts/build_arrayfire.sh @@ -1,4 +1,9 @@ #!/bin/bash + +function getLibrary { + echo "`find $1 -name $2.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;" +} + set -e set -x @@ -98,8 +103,16 @@ if [ "$use_oneapi" = "ON" ]; then set +x source /opt/intel/oneapi/setvars.sh set -x - # Additional libraries are not needed because they are provided by the runtime - #compute_library_cmake_flag+=" -DAF_ADDITIONAL_MKL_LIBRARIES:FILEPATHS=`find $TBBROOT -name libtbb.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libintlc.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libsycl.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;`find $CMPLR_ROOT/lib -name libur_loader.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`" + compute_library_cmake_flag+=" -DAF_ADDITIONAL_MKL_LIBRARIES:FILEPATHS=" + compute_library_cmake_flag+=$(getLibrary $TBBROOT libtbb) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libimf) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libsycl) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libsvml) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libirng) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libintlc) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libur_loader) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libur_adapter_opencl) + compute_library_cmake_flag+=$(getLibrary $UMF_ROOT/lib libumf) fi # Look for correct OpenCL library and headers, location depends on the distro diff --git a/test_dockers/STGZ/Dockerfile b/test_dockers/STGZ/Dockerfile index 180104f..b67718a 100644 --- a/test_dockers/STGZ/Dockerfile +++ b/test_dockers/STGZ/Dockerfile @@ -5,16 +5,11 @@ RUN apt update && apt-get -y install nvidia-compute-utils-570 wget clinfo build- RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list && \ - apt update && apt-get -y install intel-oneapi-runtime-opencl intel-oneapi-compiler-dpcpp-cpp-runtime + apt update && apt-get -y install intel-oneapi-runtime-opencl COPY ArrayFire-3.10.0-Linux.sh /usr/src RUN cd /usr/src && ./ArrayFire-3.10.0-Linux.sh --skip-license && rm ArrayFire-3.10.0-Linux.sh RUN cd /usr/src/share/ArrayFire/examples && mkdir build && cd build && \ - . /opt/intel/oneapi/setvars.sh && \ cmake -DArrayFire_DIR=/usr/src/share/ArrayFire/cmake .. && make -j 14 - -RUN echo '\n\ -# Source the runtime so we can run oneapi back end\n\ -. /opt/intel/oneapi/setvars.sh' >> /etc/bash.bashrc From 586b1e9130dd63d60b6ac617d1c2d8c0faa9fc39 Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Tue, 15 Apr 2025 13:48:32 -0700 Subject: [PATCH 4/7] Make docker-compose volumes paths relative. --- docker-compose.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 416884d..29b9ff3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,8 +27,8 @@ services: depends_on: - af_manylinux_2_28_cuda_12.8 volumes: - - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts - - /home/arrayfire/build_dockers/build_manylinux_arrayfire_mkl_2025_cuda_12_8:/usr/src + - ./arrayfire/scripts:/scripts + - ./build_manylinux_arrayfire_mkl_2025_cuda_12_8:/usr/src stdin_open: true tty: true command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo @@ -39,8 +39,8 @@ services: depends_on: - af_manylinux_2_28_cuda_12.8 volumes: - - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts - - /home/arrayfire/build_dockers/build_manylinux_arrayfire_openblas_cuda_12_8:/usr/src + - ./arrayfire/scripts:/scripts + - ./build_manylinux_arrayfire_openblas_cuda_12_8:/usr/src stdin_open: true tty: true command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo @@ -74,8 +74,8 @@ services: depends_on: - af_ubuntu_22_04_cuda_12.8 volumes: - - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts - - /home/arrayfire/build_dockers/build_ubuntu_arrayfire_mkl_2025_cuda_12_8:/usr/src + - ./arrayfire/scripts:/scripts + - ./build_ubuntu_arrayfire_mkl_2025_cuda_12_8:/usr/src stdin_open: true tty: true command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo @@ -86,8 +86,8 @@ services: depends_on: - af_ubuntu_22_04_cuda_12.8 volumes: - - /home/arrayfire/build_dockers/arrayfire/scripts:/scripts - - /home/arrayfire/build_dockers/build_ubuntu_arrayfire_openblas_cuda_12_8:/usr/src + - ./arrayfire/scripts:/scripts + - ./build_ubuntu_arrayfire_openblas_cuda_12_8:/usr/src stdin_open: true tty: true command: "/scripts/build_arrayfire.sh --build-type RelWithDebInfo From 5c31f6c1503b11cf22b9b235c379f01b6b4e8efc Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Wed, 16 Apr 2025 12:39:37 -0700 Subject: [PATCH 5/7] Install additional libraries required for the oneAPI back end. Library run paths needed to be patched. --- arrayfire/manylinux/dev_base/Dockerfile | 2 +- arrayfire/scripts/build_arrayfire.sh | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arrayfire/manylinux/dev_base/Dockerfile b/arrayfire/manylinux/dev_base/Dockerfile index a3fab21..b96c009 100644 --- a/arrayfire/manylinux/dev_base/Dockerfile +++ b/arrayfire/manylinux/dev_base/Dockerfile @@ -6,7 +6,7 @@ RUN dnf update -y && \ wget freetype-devel fontconfig-devel \ fftw-devel openblas-devel lapack-devel \ glfw-devel graphviz graphviz-devel \ - mesa-libGLU-devel freeimage-devel && \ + mesa-libGLU-devel freeimage-devel patchelf && \ dnf clean all # Set location for OpenCL library diff --git a/arrayfire/scripts/build_arrayfire.sh b/arrayfire/scripts/build_arrayfire.sh index c5891e6..57f5ae7 100755 --- a/arrayfire/scripts/build_arrayfire.sh +++ b/arrayfire/scripts/build_arrayfire.sh @@ -1,7 +1,13 @@ #!/bin/bash function getLibrary { - echo "`find $1 -name $2.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;" + find $1 -name $2.so* -exec cp "{}" /tmp \; + find /tmp -name $2.so* -exec patchelf --set-rpath '$ORIGIN' "{}" \; + echo "`find /tmp -name $2.so* | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;" +} + +function getFile { + echo "`find $1 -name $2 | xargs | awk '{ gsub(\" \",\";\",$0); print $0 }'`;" } set -e @@ -112,6 +118,14 @@ if [ "$use_oneapi" = "ON" ]; then compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libintlc) compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libur_loader) compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libur_adapter_opencl) + compute_library_cmake_flag+=$(getFile $CMPLR_ROOT/lib cl.cfg) + compute_library_cmake_flag+=$(getFile $CMPLR_ROOT/lib clbltfn*.rtl) + compute_library_cmake_flag+=$(getFile $CMPLR_ROOT/lib cllibrary.rtl) + compute_library_cmake_flag+=$(getFile $CMPLR_ROOT/lib cllibrary*.o) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libcommon_clang) + compute_library_cmake_flag+=$(getLibrary $TCM_ROOT/lib libhwloc) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libintelocl) + compute_library_cmake_flag+=$(getLibrary $CMPLR_ROOT/lib libocl_svml_*) compute_library_cmake_flag+=$(getLibrary $UMF_ROOT/lib libumf) fi From 21f5a59e62afaa865e0148e215e41a4e76e9357e Mon Sep 17 00:00:00 2001 From: Edwin Date: Tue, 29 Apr 2025 13:06:16 -0700 Subject: [PATCH 6/7] Dockerized arrayfire python wheels --- arrayfire/manylinux/cuda_deps/Dockerfile | 15 ++++---- arrayfire/manylinux/dev_base/Dockerfile | 10 ++++- arrayfire/manylinux/wheels/Dockerfile | 7 ++++ arrayfire/scripts/build_wheel.sh | 47 ++++++++++++++++++++++++ docker-compose.yml | 30 ++++++++++++++- 5 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 arrayfire/manylinux/wheels/Dockerfile create mode 100644 arrayfire/scripts/build_wheel.sh diff --git a/arrayfire/manylinux/cuda_deps/Dockerfile b/arrayfire/manylinux/cuda_deps/Dockerfile index bb329d9..ba53a8b 100644 --- a/arrayfire/manylinux/cuda_deps/Dockerfile +++ b/arrayfire/manylinux/cuda_deps/Dockerfile @@ -1,20 +1,21 @@ FROM af/manylinux/dependencies MAINTAINER Christophe Murphy -ARG AF_CUDA_VERSION +ARG AF_CUDA_MAJOR_VERSION +ARG AF_CUDA_MINOR_VERSION RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && \ dnf clean all && \ - dnf -y install cuda-toolkit-${AF_CUDA_VERSION} && \ - dnf -y install cudnn-cuda-${AF_CUDA_VERSION} && \ + dnf -y install cuda-toolkit-${AF_CUDA_MAJOR_VERSION}-${AF_CUDA_MINOR_VERSION} && \ + dnf -y install cudnn-cuda-${AF_CUDA_MAJOR_VERSION}-${AF_CUDA_MINOR_VERSION} && \ dnf clean all # Create Nvidia's ICD and missing standard simlinks for the CUDA driver and OpenCL RUN mkdir -p /etc/OpenCL/vendors && \ echo "/usr/local/cuda/targets/x86_64-linux/lib/libOpenCL.so" > /etc/OpenCL/vendors/nvidia.icd && \ ldconfig && \ - ln -s /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so \ - /usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so.1 + ln -s /usr/local/cuda-${AF_CUDA_MAJOR_VERSION}.${AF_CUDA_MINOR_VERSION}/targets/x86_64-linux/lib/stubs/libcuda.so \ + /usr/local/cuda-${AF_CUDA_MAJOR_VERSION}.${AF_CUDA_MINOR_VERSION}/targets/x86_64-linux/lib/stubs/libcuda.so.1 -ENV PATH /usr/local/cuda/bin:${PATH} -ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:${LD_LIBRARY_PATH} +ENV PATH=/usr/local/cuda/bin:${PATH} +ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} diff --git a/arrayfire/manylinux/dev_base/Dockerfile b/arrayfire/manylinux/dev_base/Dockerfile index b96c009..b6739fb 100644 --- a/arrayfire/manylinux/dev_base/Dockerfile +++ b/arrayfire/manylinux/dev_base/Dockerfile @@ -7,11 +7,17 @@ RUN dnf update -y && \ fftw-devel openblas-devel lapack-devel \ glfw-devel graphviz graphviz-devel \ mesa-libGLU-devel freeimage-devel patchelf && \ + dnf -y install gcc-toolset-10 &&\ dnf clean all + # Set location for OpenCL library -ENV OCL_ROOT /usr -ENV OPENCL_ROOT /usr +ENV OCL_ROOT=/usr +ENV OPENCL_ROOT=/usr +ENV PATH=/opt/rh/gcc-toolset-10/root/usr/bin:${PATH} +ENV LD_LIBRARY_PATH=/opt/rh/gcc-toolset-10/root/usr/lib64:/opt/rh/gcc-toolset-10/root/usr/lib:/opt/rh/gcc-toolset-10/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-10/root/usr/lib/dyninst:${LD_LIBRARY_PATH} +ENV CC=/opt/rh/gcc-toolset-10/root/bin/gcc +ENV CXX=/opt/rh/gcc-toolset-10/root/bin/c++ # Ninja build system RUN cd /usr/src && \ diff --git a/arrayfire/manylinux/wheels/Dockerfile b/arrayfire/manylinux/wheels/Dockerfile new file mode 100644 index 0000000..32cb1ab --- /dev/null +++ b/arrayfire/manylinux/wheels/Dockerfile @@ -0,0 +1,7 @@ +ARG AF_CUDA_MAJOR_VERSION=12 +ARG AF_CUDA_MINOR_VERSION=8 +FROM af/manylinux/cuda:${AF_CUDA_MAJOR_VERSION}.${AF_CUDA_MINOR_VERSION} + +ARG AF_PYTHON_VERSION +ENV AF_PYTHON_VERSION=${AF_PYTHON_VERSION} +RUN dnf install -y python${AF_PYTHON_VERSION} \ No newline at end of file diff --git a/arrayfire/scripts/build_wheel.sh b/arrayfire/scripts/build_wheel.sh new file mode 100644 index 0000000..e2ec270 --- /dev/null +++ b/arrayfire/scripts/build_wheel.sh @@ -0,0 +1,47 @@ +#!/bin/bash + + +#set up opencl +cd /usr/src +if [[ ! -d OpenCL-Headers/ ]]; then +git clone https://github.com/KhronosGroup/OpenCL-Headers.git +fi +cd /usr/src/OpenCL-Headers +cmake -B build -DCMAKE_INSTALL_PREFIX=/usr +cmake --build build --target install -j + +cd /usr/src +if [[ ! -d OpenCL-CLHPP/ ]]; then +git clone https://github.com/KhronosGroup/OpenCL-CLHPP.git +fi +cd /usr/src/OpenCL-CLHPP +cmake -B build -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF +cmake --build build --target install -j + +#build wrapper +python$AF_PYTHON_VERSION -m pip uninstall -y arrayfire* + +cd /usr/src +if [[ ! -d arrayfire-binary-python-wrapper/ ]]; then +git clone https://github.com/edwinsolisf/arrayfire-binary-python-wrapper.git --branch afwheel310 +fi +cd /usr/src/arrayfire-binary-python-wrapper +git pull origin afwheel310 +source /opt/intel/oneapi/setvars.sh +export AF_BUILD_LOCAL_LIBS=1 +export CMAKE_BUILD_PARALLEL_LEVEL=3 +python$AF_PYTHON_VERSION -m pip install -r requirements.txt +python$AF_PYTHON_VERSION -m build --wheel -v + +#test wrapper +python$AF_PYTHON_VERSION -m pip install dist/arrayfire_binary_python_wrapper-0.8.0+af3.10.0-py3-none-linux_x86_64.whl +cd /usr/src +if [[ ! -d arrayfire-py/ ]]; then +git clone https://github.com/edwinsolisf/arrayfire-py.git --branch afwheel310 +fi +cd /usr/src/arrayfire-py +git pull origin afwheel310 +python$AF_PYTHON_VERSION -m pip install -r requirements.txt +python$AF_PYTHON_VERSION -m build --wheel -v +python$AF_PYTHON_VERSION -m pip install dist/arrayfire* +python$AF_PYTHON_VERSION -m pytest \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 29b9ff3..5e02bdf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,11 +17,39 @@ services: build: context: ./arrayfire/manylinux/cuda_deps args: - AF_CUDA_VERSION: 12-8 + AF_CUDA_MAJOR_VERSION: 12 + AF_CUDA_MINOR_VERSION: 8 image: af/manylinux/cuda:12.8 depends_on: - af_manylinux_2_28_deps + af_manylinux_2_28_cuda_12.6: + build: + context: ./arrayfire/manylinux/cuda_deps + args: + AF_CUDA_MAJOR_VERSION: 12 + AF_CUDA_MINOR_VERSION: 6 + image: af/manylinux/cuda:12.6 + depends_on: + - af_manylinux_2_28_deps + + af_manylinux_2_28_arrayfire_pywheel_3_11: + image: af/manylinux/pywheel:3.11 + depends_on: + - af_manylinux_2_28_cuda_12.6 + build: + context: ./arrayfire/manylinux/wheels + args: + AF_CUDA_MAJOR_VERSION: 12 + AF_CUDA_MINOR_VERSION: 6 + AF_PYTHON_VERSION: 3.11 + volumes: + - ./arrayfire/scripts:/scripts + - ./build_manylinux_arrayfire_pywheel_3_11:/usr/src + stdin_open: true + tty: true + command: "/scripts/build_wheel.sh" + af_manylinux_2_28_arrayfire_mkl: image: af/manylinux/cuda:12.8 depends_on: From 6af444dfad9b7dededb320bbff4b5254a15813e4 Mon Sep 17 00:00:00 2001 From: Edwin Date: Thu, 1 May 2025 21:09:13 -0700 Subject: [PATCH 7/7] Moved arrayfire build flags to docker argument --- arrayfire/manylinux/wheels/Dockerfile | 44 +++++++++++++++++++++++++-- arrayfire/scripts/build_wheel.sh | 6 ++-- docker-compose.yml | 28 ++++++++++++++++- 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/arrayfire/manylinux/wheels/Dockerfile b/arrayfire/manylinux/wheels/Dockerfile index 32cb1ab..1797cc5 100644 --- a/arrayfire/manylinux/wheels/Dockerfile +++ b/arrayfire/manylinux/wheels/Dockerfile @@ -2,6 +2,44 @@ ARG AF_CUDA_MAJOR_VERSION=12 ARG AF_CUDA_MINOR_VERSION=8 FROM af/manylinux/cuda:${AF_CUDA_MAJOR_VERSION}.${AF_CUDA_MINOR_VERSION} -ARG AF_PYTHON_VERSION -ENV AF_PYTHON_VERSION=${AF_PYTHON_VERSION} -RUN dnf install -y python${AF_PYTHON_VERSION} \ No newline at end of file +ARG AF_PYTHON_MAJOR_VERSION +ARG AF_PYTHON_MINOR_VERSION + +ENV AF_PYTHON_MAJOR_VERSION=${AF_PYTHON_MAJOR_VERSION} +ENV AF_PYTHON_MINOR_VERSION=${AF_PYTHON_MINOR_VERSION} +ENV AF_PYTHON_VERSION=${AF_PYTHON_MAJOR_VERSION}.${AF_PYTHON_MINOR_VERSION} +RUN dnf install -y python${AF_PYTHON_VERSION} + +# BACKENDS +ARG AF_BUILD_OPENCL +ENV AF_BUILD_OPENCL=${AF_BUILD_OPENCL} +ARG AF_BUILD_CUDA +ENV AF_BUILD_CUDA=${AF_BUILD_CUDA} +ARG AF_BUILD_ONEAPI +ENV AF_BUILD_ONEAPI=${AF_BUILD_ONEAPI} + +# CPU BACKEND +ARG AF_COMPUTE_LIBRARY +ENV AF_COMPUTE_LIBRARY=${AF_COMPUTE_LIBRARY} + +# CUDA BACKEND +ARG AF_WITH_STATIC_CUDA_NUMERIC_LIBS +ENV AF_WITH_STATIC_CUDA_NUMERIC_LIBS=${AF_WITH_STATIC_CUDA_NUMERIC_LIBS} +ARG AF_CUDA_ARCHITECTURES +ENV AF_CUDA_ARCHITECTURES=${AF_CUDA_ARCHITECTURES} + +# UTILS +ARG AF_WITH_IMAGEIO +ENV AF_WITH_IMAGEIO=${AF_WITH_IMAGEIO} +ARG AF_BUILD_FORGE +ENV AF_BUILD_FORGE=${AF_BUILD_FORGE} + +# FORGE flags if Forge enabled +ARG FG_USE_STATIC_CPPFLAGS +ENV FG_USE_STATIC_CPPFLAGS=${FG_USE_STATIC_CPPFLAGS} +ARG FG_WITH_FREEIMAGE +ENV FG_WITH_FREEIMAGE=${FG_WITH_FREEIMAGE} + +# CMAKE PARALLEL THREADS +ARG CMAKE_BUILD_PARALLEL_LEVEL +ENV CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL} \ No newline at end of file diff --git a/arrayfire/scripts/build_wheel.sh b/arrayfire/scripts/build_wheel.sh index e2ec270..c222e1e 100644 --- a/arrayfire/scripts/build_wheel.sh +++ b/arrayfire/scripts/build_wheel.sh @@ -29,9 +29,11 @@ cd /usr/src/arrayfire-binary-python-wrapper git pull origin afwheel310 source /opt/intel/oneapi/setvars.sh export AF_BUILD_LOCAL_LIBS=1 -export CMAKE_BUILD_PARALLEL_LEVEL=3 python$AF_PYTHON_VERSION -m pip install -r requirements.txt -python$AF_PYTHON_VERSION -m build --wheel -v + +CMAKE_ARGS="-DAF_BUILD_OPENCL=$AF_BUILD_OPENCL -DAF_BUILD_CUDA=$AF_BUILD_CUDA -DAF_BUILD_ONEAPI=$AF_BUILD_ONEAPI -DAF_COMPUTE_LIBRARY=$AF_COMPUTE_LIBRARY \ +-DAF_BUILD_FORGE=$AF_BUILD_FORGE -DAF_WITH_STATIC_CUDA_NUMERIC_LIBS=$AF_WITH_STATIC_CUDA_NUMERIC_LIBS -DAF_WITH_IMAGEIO=$AF_WITH_IMAGEIO \ +-DCUDA_architecture_build_targets=$AF_CUDA_ARCHITECTURES -DFG_USE_STATIC_CPPFLAGS=$FG_USE_STATIC_CPPFLAGS -DFG_WITH_FREEIMAGE=$FG_WITH_FREEIMAGE" python$AF_PYTHON_VERSION -m build --wheel -v #test wrapper python$AF_PYTHON_VERSION -m pip install dist/arrayfire_binary_python_wrapper-0.8.0+af3.10.0-py3-none-linux_x86_64.whl diff --git a/docker-compose.yml b/docker-compose.yml index 5e02bdf..75c88fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,9 +40,35 @@ services: build: context: ./arrayfire/manylinux/wheels args: + ### ENVIRONMENT FLAGS ### AF_CUDA_MAJOR_VERSION: 12 AF_CUDA_MINOR_VERSION: 6 - AF_PYTHON_VERSION: 3.11 + AF_PYTHON_MAJOR_VERSION: 3 + AF_PYTHON_MINOR_VERSION: 11 + + ### ARRAYFIRE BUILD FLAGS ### + AF_BUILD_OPENCL: "ON" + AF_BUILD_CUDA: "ON" + AF_BUILD_ONEAPI: "ON" + + # CPU BACKEND + AF_COMPUTE_LIBRARY: "Intel-MKL" + + # CUDA BACKEND + AF_WITH_STATIC_CUDA_NUMERIC_LIBS: "OFF" + AF_CUDA_ARCHITECTURES: "5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0;9.0+PTX" + + # UTILS + AF_WITH_IMAGEIO: "ON" + AF_BUILD_FORGE: "ON" + + # FORGE flags if Forge enabled + FG_USE_STATIC_CPPFLAGS: "OFF" + FG_WITH_FREEIMAGE: "OFF" + + # CMAKE PARALLEL THREADS + CMAKE_BUILD_PARALLEL_LEVEL: 4 + volumes: - ./arrayfire/scripts:/scripts - ./build_manylinux_arrayfire_pywheel_3_11:/usr/src