diff --git a/.gitignore b/.gitignore index 43388e9cb..475634868 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.vscode *.cache *.code-workspace +miscs/apptainer/vortex_fpga.sif diff --git a/docs/fpga_setup.md b/docs/fpga_setup.md index d909d8687..844a5e89a 100644 --- a/docs/fpga_setup.md +++ b/docs/fpga_setup.md @@ -63,6 +63,12 @@ $ source /opt/xilinx/xrt/setup.sh $ source /tools/reconfig/xilinx/Vitis/2023.1/settings64.sh ``` +If you are using an apptainer, +``` +$ export LD_LIBRARY_PATH=/opt/boost-1.66/lib/:/opt/openssl-1.1/lib/:$LD_LIBRARY_PATH +``` + + ### Check Installed FPGA Platforms `platforminfo -l` which tells us the correct name of the platform installed on the current fpga node. It should be used for the `PLATFORM` variable below. Otherwise, if there is an error then there was an issue with the previous two commands. diff --git a/miscs/apptainer/README.md b/miscs/apptainer/README.md new file mode 100644 index 000000000..6da64d62c --- /dev/null +++ b/miscs/apptainer/README.md @@ -0,0 +1,39 @@ +# Apptainer Build Process + +Use the Slurm scheduler to request an interactive job on Flubber9 +``` +salloc -p rg-fpga --nodes=1 --ntasks-per-node=64 --mem=16G --nodelist flubber9 --time=01:00:00 +``` + +Go to `apptainer` directory + +``` +$ pwd +vortex/miscs/apptainer + +$ apptainer build --no-https vortex_fpga.sif vortex_fpga.def + +``` +To start the apptainer, +``` +$ apptainer shell --fakeroot --cleanenv --writable-tmpfs --bind /opt/xilinx/:/opt/xilinx/ --bind /netscratch/rn84/devnull:/dev/null --bind /dev/bus/usb,/sys/bus/pci --bind /projects:/projects --bind /tools:/tools --bind /netscratch:/netscratch vortex_fpga.sif +``` + +Inside the Apptainer, +``` +Apptainer> lsusb + +should show devices connected to machine on which you are running this command +``` + + +``` +Apptainer> source /opt/xilinx/xrt/setup.sh +Apptainer> source /tools/reconfig/xilinx/Vitis/2023.1/settings64.sh + +Apptainer> platforminfo -l +``` + + + + diff --git a/miscs/apptainer/boost-package.deb b/miscs/apptainer/boost-package.deb new file mode 100644 index 000000000..0d6044d24 Binary files /dev/null and b/miscs/apptainer/boost-package.deb differ diff --git a/miscs/apptainer/install_boost_openssl.sh b/miscs/apptainer/install_boost_openssl.sh new file mode 100644 index 000000000..47fff3a1c --- /dev/null +++ b/miscs/apptainer/install_boost_openssl.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e # Exit on error +echo "Installing Boost and OpenSSL from .deb packages" + +# Extract and install Boost +echo "Extracting Boost..." +ar -x boost-package.deb +ls +mkdir -p /tmp/boost-extract +tar --zstd --no-same-owner -xvf data.tar.zst -C /tmp/boost-extract +ls -l /tmp/boost-extract/ +cp -r /tmp/boost-extract/opt/boost-1.66/ /opt/ +ls -l /opt/boost-1.66/ +rm -rf data.tar + +# Extract and install OpenSSL +echo "Extracting OpenSSL..." +ar -x openssl-package.deb +mkdir -p /tmp/openssl-extract +tar --zstd --no-same-owner -xvf data.tar.zst -C /tmp/openssl-extract +ls -l /tmp/openssl-extract/ +cp -r /tmp/openssl-extract/opt/openssl-1.1/ /opt/ +ls -l /opt/openssl-1.1/ +rm -rf data.tar + + + +echo "Boost and OpenSSL installation complete!" diff --git a/miscs/apptainer/openssl-package.deb b/miscs/apptainer/openssl-package.deb new file mode 100644 index 000000000..2bc6aac74 Binary files /dev/null and b/miscs/apptainer/openssl-package.deb differ diff --git a/miscs/apptainer/vortex_fpga.def b/miscs/apptainer/vortex_fpga.def new file mode 100644 index 000000000..d35989690 --- /dev/null +++ b/miscs/apptainer/vortex_fpga.def @@ -0,0 +1,97 @@ +Bootstrap: docker +From: ubuntu:22.04 + + +%files + install_boost_openssl.sh . + openssl-package.deb . + boost-package.deb . + +%post + echo "Setting up the environment..." + + + touch /var/log/apt/term.log + if [ -f /var/log/apt/term.log ]; then + chown root:adm /var/log/apt/term.log || true + fi + + + # Set environment variable to avoid interactive prompts during installation + export DEBIAN_FRONTEND=noninteractive + echo 'APT::Sandbox::User "root";' > /etc/apt/apt.conf.d/no-sandbox + mkdir -p /netscratch + + # Update and install base dependencies + apt-get update + apt-get install -y libc6 fakeroot + + # Fix dependency issues + apt-get install -f -y || true + dpkg --configure -a || true + + # Reinstall problematic packages + apt-get remove --purge -y dbus fontconfig-config || true + apt-get install -y dbus fontconfig-config || true + + rm -f /var/lib/dpkg/lock-frontend + rm -f /var/lib/dpkg/lock + rm -f /var/cache/apt/archives/lock + + # mount -o remount,rw /usr + # mount -o remount,rw /var + chown -R root:root /usr/lib/dbus-1.0/dbus-daemon-launch-helper || true + + + # Install necessary packages + apt-get install -y fontconfig libfontconfig1 libpangoft2-1.0-0 libbluray2 \ + libpangocairo-1.0-0 libavformat58 libpango-1.0-0 \ + openjdk-11-jre-headless libcairo2 librsvg2-2 librsvg2-common \ + openjdk-11-jre-zero libtheora0 libavcodec58 libcairo-gobject2 \ + ca-certificates-java libchromaprint1 software-properties-common perl-modules bzip2 \ + unzip zlib1g-dev libtinfo5 g++ usbutils gawk bison gcc make wget tar python3.9 locales zstd uuid-dev git || true + + ln -s /usr/bin/python3 /usr/bin/python + + locale-gen en_US.UTF-8 + update-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 + + # Run dpkg to ensure everything is properly configured + dpkg --configure -a || true + + # Clean up apt cache + apt-get clean + rm -rf /var/lib/apt/lists/* + + echo "Setting up the environment..." + + # Copy the installation script into the container + cp install_boost_openssl.sh /tmp/ + + # Execute the script + chmod +x /tmp/install_boost_openssl.sh + /tmp/install_boost_openssl.sh + + # Clean up + rm -f /tmp/install_boost_openssl.sh + +%environment + export LANG=en_US.UTF-8 + export LANGUAGE=en_US.UTF-8 + export LC_ALL=en_US.UTF-8 + export HOME=/home/developer + + + +%runscript + exec /bin/bash + +%labels + Author Rahul + Version 1.0 + +%test + echo "Container test successful!" + locale + lsusb || echo "lsusb not available" + ls -l /dev/null