diff --git a/scripts/linux/Dockerfile b/scripts/linux/Dockerfile index e3de3be..cfa5feb 100644 --- a/scripts/linux/Dockerfile +++ b/scripts/linux/Dockerfile @@ -1,11 +1,11 @@ -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT FROM ubuntu:24.04 ARG BUILD_TEMPDIR ARG LIC_MAC=00:00:00:00:00:00 -ENV LIC_MAC=${LIC_MAC} +ENV LIC_MAC ${LIC_MAC} ARG USER_ID ARG GROUP_ID @@ -14,7 +14,8 @@ ARG GROUP_NAME SHELL ["/bin/bash", "-c"] RUN apt-get update -RUN apt-get install -y sudo adduser perl +RUN apt-get install -y --install-recommends linux-generic-hwe-24.04 +RUN apt-get install -y sudo adduser perl ocl-icd-libopencl1 RUN deluser --remove-home $(getent passwd | awk -F: -v uid="$USER_ID" '$3 == uid {print $1}') || echo "Ignoring error, as uid:${USER_ID} does not exist" RUN groupadd -g ${GROUP_ID} ${GROUP_NAME} || echo "Ignoring error, as ${GROUP_NAME} already exists" @@ -39,7 +40,7 @@ ENV LC_ALL en_US.UTF-8 RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo -E apt-get install -y tzdata RUN git clone https://github.com/amd/xdna-driver.git --recursive -RUN cd xdna-driver/ && git checkout f60608b +RUN cd xdna-driver/ && git checkout 176d6ec7a5b65767d02a4bae477962456ac8c3f4 RUN cd xdna-driver/ && git submodule update --recursive RUN sudo chmod +x /home/riallto/xdna-driver/xrt/src/runtime_src/tools/scripts/xrtdeps.sh RUN sudo /home/riallto/xdna-driver/xrt/src/runtime_src/tools/scripts/xrtdeps.sh -docker @@ -49,7 +50,8 @@ COPY $BUILD_TEMPDIR/root/debs npu_ubuntu_debs RUN sudo apt-get install -y dkms udev python3 RUN sudo apt-get install -y python3-pip ocl-icd-opencl-dev uuid-dev libopencv-dev python3-opencv -RUN sudo -E dpkg -i npu_ubuntu_debs/xrt_*-amd64-xrt.deb +RUN sudo -E dpkg -i npu_ubuntu_debs/xrt_*-amd64-base.deb +RUN sudo -E dpkg -i npu_ubuntu_debs/xrt_*-amd64-base-dev.deb RUN sudo -E dpkg -i npu_ubuntu_debs/xrt_plugin*-amdxdna.deb RUN git clone https://github.com/AMDResearch/Riallto --depth=1 @@ -91,7 +93,6 @@ RUN source ~/.bashrc && python3 -m pip install notebook #Cleanup a bit RUN rm -rf /home/riallto/*.tar.gz -ENV SHELL=/bin/bash +ENV SHELL /bin/bash CMD ["/bin/bash", "-l", "-c", "jupyterhub-singleuser", "--allow-root"] - diff --git a/scripts/linux/README.md b/scripts/linux/README.md index c481a3a..9689b3d 100644 --- a/scripts/linux/README.md +++ b/scripts/linux/README.md @@ -1,55 +1,51 @@ -# Riallto Ubuntu 24.04 setup +# Riallto Ubuntu 24.04.2 setup -Currently there is support for bringing up Riallto on Ubuntu 24.04 with docker. +Currently there is support for bringing up Riallto on Ubuntu 24.04.2 with docker. To use Riallto on Linux requires the use of the [xdna-driver](https://github.com/amd/xdna-driver) which is installed as part of the setup. -This driver requires version 6.10+ of the Linux kernel, these scripts will upgrade a standard Ubuntu 24.04 installation to this kernel version. __Using this kernel version will require disabling secure boot on your device.__ +This driver requires version 6.10+ of the Linux kernel, we ask you to first upgrade to Ubuntu 24.04.2 from a Ubuntu 24.04 installation to install a 6.11 kernel. __Using this kernel version will require disabling secure boot on your device.__ ## Install steps On an NPU enabled laptop running Ubuntu 24.04. -1. __Setup Docker.__ +1. **Upgrade to Ubuntu 24.04.2** -You can follow the steps [here](https://docs.docker.com/engine/install/ubuntu/). + ```sh + sudo apt update + sudo apt install --install-recommends linux-generic-hwe-24.04 + sudo reboot + ``` + +2. **Setup Docker** + + You can follow the steps [here](https://docs.docker.com/engine/install/ubuntu/). -2. __Add your user to the docker user group and then relogin.__ +3. **Add your user to the docker user group and then relogin** ```sh sudo usermod -aG docker $USER ; exit ``` -3. __Obtain a license file for Riallto.__ +4. **Obtain a license file for Riallto** Please follow the [guide here](https://riallto.ai/prerequisites-aie-license.html#prerequisites-aie-license) to get the license. -4. __Disable secure boot from your BIOS settings.__ +5. **Disable secure boot from your BIOS settings** For now we are using an unsigned kernel version requiring that secure boot is disabled before it can be used. To disable secure boot there is a [guide](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/disabling-secure-boot?view=windows-11) from Microsoft here, but often the steps depend on your hardware manufacturer. -5. __Clone the `Riallto` repository and then navigate to the installation script.__ +6. **Clone the `Riallto` repository and then navigate to the installation script** ```sh - git clone https://github.com/AMDResearch/Riallto.git -b v1.1 + git clone https://github.com/AMDResearch/Riallto.git -b v1.1.1 cd Riallto/scripts/linux/ ``` ```{note} - We recommend using the tag v1.1 to get the verified version of Riallto. Install from `main` to get the latest drivers and code, however, this is not thoroughly verified. - ``` - -6. __Upgrade Linux Kernel.__ - - ```sh - ./setup_riallto_linux.sh + We recommend using the tag v1.1.1 to get the verified version of Riallto. Install from `main` to get the latest drivers and code, however, this is not thoroughly verified. ``` - This command will check the kernel version and if the `xdna-driver` has been installed. If the Linux kernel is not `6.10` or the NPU device drivers are missing, it will build them within a docker and install them on the host machine. This takes about 10 minutes to run and after completing successfully the user will be asked to restart. - -7. __Reboot the machine.__ - - This will finish upgrading the Linux kernel to `6.10`. - -8. __Install Riallto by creating its Docker container.__ +7. **Install Riallto by creating its Docker container** ```sh ./setup_riallto_linux.sh @@ -110,6 +106,8 @@ This means that secure boot has not been disabled from the machine and it cannot ### If the Docker container does not start with `launch_jupyter.sh` or `run_pytest.sh` because of the `/dev/accel/accel0` does not exist +First of all, confirm that secure boot is disabled on the BIOS. + Check `dmesg` ```sh diff --git a/scripts/linux/create_container.sh b/scripts/linux/create_container.sh index 9443899..fade79c 100755 --- a/scripts/linux/create_container.sh +++ b/scripts/linux/create_container.sh @@ -1,12 +1,13 @@ #!/bin/bash # -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT docker run -dit --rm --name riallto_docker \ --cap-add=NET_ADMIN \ -v $(pwd):/workspace \ --device=/dev/accel/accel0:/dev/accel/accel0 \ + --ulimit memlock=-1:-1 \ -w /workspace \ riallto:latest \ /bin/bash diff --git a/scripts/linux/launch_jupyter.sh b/scripts/linux/launch_jupyter.sh index 6f43fec..b4b3c8b 100755 --- a/scripts/linux/launch_jupyter.sh +++ b/scripts/linux/launch_jupyter.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT # Check input args @@ -25,6 +25,7 @@ docker container wait riallto_jupyter > /dev/null 2>&1 || true webcams=$(ls /dev/video*) cmd="docker run -dit --rm --name riallto_jupyter" cmd+=" --cap-add=NET_ADMIN --device=/dev/accel/accel0:/dev/accel/accel0" +cmd+=" --ulimit memlock=-1:-1 " cmd+=" -p 8888:8888 " cmd+=" -v $ABS_DIR:/notebooks " for cam in $webcams; do diff --git a/scripts/linux/run_pytest.sh b/scripts/linux/run_pytest.sh index 5beff02..9e2c297 100755 --- a/scripts/linux/run_pytest.sh +++ b/scripts/linux/run_pytest.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT docker container stop riallto_pytest || true @@ -10,6 +10,7 @@ docker run -dit --rm --name riallto_pytest \ --cap-add=NET_ADMIN \ -v $(pwd):/workspace \ --device=/dev/accel/accel0:/dev/accel/accel0 \ + --ulimit memlock=-1:-1 \ -w /workspace \ riallto:latest \ /bin/bash diff --git a/scripts/linux/setup_riallto_linux.sh b/scripts/linux/setup_riallto_linux.sh index 145ca52..266b68b 100755 --- a/scripts/linux/setup_riallto_linux.sh +++ b/scripts/linux/setup_riallto_linux.sh @@ -1,30 +1,19 @@ #!/bin/bash -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT set -e -KERNEL_VERSION="6.10-rc2" -KERNEL_VERSION_FULL="6.10.0-061000rc2" -BUILD_DATE="202406022333" - DRIVER_TARBALL=ubuntu24.04_npu_drivers.tar.gz -REQUIRED_KERNEL_VERSION="${KERNEL_VERSION_FULL}-generic" NPU_FIRMWARE="/lib/firmware/amdnpu/1502_00/npu.sbin" -KERNEL_HEADERS="linux-headers-${KERNEL_VERSION_FULL}_${KERNEL_VERSION_FULL}.${BUILD_DATE}_all.deb" -KERNEL_HEADERS_GENERIC="linux-headers-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" -KERNEL_MODULES="linux-modules-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" -KERNEL_IMAGE="linux-image-unsigned-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" MLIR_FILE="https://www.xilinx.com/bin/public/openDownload?filename=pynqMLIR_AIE_py312_v0.9.tar.gz" RIALLTO_FILE="https://www.xilinx.com/bin/public/openDownload?filename=Riallto-v1.1.zip" - ############# CHECKS ################################## # Check to ensure key URLs are accessible URLS=( -"https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/" $MLIR_FILE $RIALLTO_FILE "https://github.com/amd/xdna-driver.git" @@ -50,10 +39,10 @@ for URL in "${URLS[@]}"; do fi done -# Check that we are on Ubuntu24.04 +# Check that we are on Ubuntu24.04.2 distro_info=$(lsb_release -d) -if [[ $distro_info != *"Ubuntu 24.04"* ]]; then - echo "Riallto is only currently supported on Ubuntu 24.04" +if [[ $distro_info != *"Ubuntu 24.04.2"* ]]; then + echo "Riallto is only currently supported on Ubuntu 24.04.2" exit 1 fi @@ -93,47 +82,14 @@ echo "Found a License file associated with MAC address $MAC" ######### Kernel and NPU driver check / install ########### # Check to see if the kernel version and NPU driver is already installed build_xrt=0 -kernel_version=$(uname -r) - -if [[ "$kernel_version" == "$REQUIRED_KERNEL_VERSION" ]]; then - echo "Kernel version is okay, is NPU available?" -else - echo "To install Riallto requires upgrading your kernel to ${REQUIRED_KERNEL_VERSION}" - echo "WARNING: This can be quite disruptive to your system configuration." - echo "After upgrading you will have to restart your machine and rerun this script" - while true; do - read -p "Are you happy to continue? [Y/N] " answer - case $answer in - [Yy]* ) echo "You chose yes, attempting to update kernel"; break;; - [Nn]* ) echo "Exiting"; exit 1;; - * ) echo "Please chose Y or N.";; - esac - done - - # First check to make sure that secure boot is disabled. - if mokutil --sb-state | grep -q "enabled"; then - echo "Secure boot is currently enabled." - echo "To install Riallto on Linux currently requires a" - echo "non-mainline kernel version ${REQUIRED_KERNEL_VERSION}." - echo "If you would like to continue with the installation " - echo "please disable secure boot in your bios settings and rerun this script." - exit 1 - fi - _kbump_dir=$(mktemp -d) - wget -P ${_kbump_dir} https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_HEADERS_GENERIC - wget -P ${_kbump_dir} https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_HEADERS - wget -P ${_kbump_dir} https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_IMAGE - wget -P ${_kbump_dir} https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_MODULES - - pushd $_kbump_dir/ - sudo dpkg -i $KERNEL_HEADERS - sudo dpkg -i $KERNEL_HEADERS_GENERIC - sudo dpkg -i $KERNEL_MODULES - sudo dpkg -i $KERNEL_IMAGE - popd - echo -e "\033[31mPlease now restart your machine and rerun the script.\033[0m" +# First check to make sure that secure boot is disabled. +if mokutil --sb-state | grep -q "enabled"; then + echo "Secure boot is currently enabled." + echo "To install Riallto on Linux currently requires to compile the XDNA driver." + echo "If you would like to continue with the installation " + echo "please disable secure boot in your BIOS settings and rerun this script." exit 1 fi @@ -145,8 +101,7 @@ else fi if [ $build_xrt -eq 1 ]; then - # Building the NPU driver version and installing it - + # Building the NPU driver if [ ! -f "./xdna-driver-builder/${DRIVER_TARBALL}" ]; then echo "xdna-driver-builder/${DRIVER_TARBALL} is missing, building it from scratch" pushd xdna-driver-builder @@ -158,14 +113,18 @@ if [ $build_xrt -eq 1 ]; then fi -# Build the NPU drivers (xdna-driver) +# Install the NPU drivers in the host (xdna-driver) if [ ! -f "${NPU_FIRMWARE}" ]; then npu_install_tmp_dir=$(mktemp -d) tar -xzvf "./xdna-driver-builder/${DRIVER_TARBALL}" -C "${npu_install_tmp_dir}" pushd $npu_install_tmp_dir/root/debs - sudo -E dpkg -i xrt_*-amd64-xrt.deb || true - sudo -E dpkg -i xrt_plugin*-amdxdna.deb || true + packages=$(dpkg -l | awk '/^ii/ && $2 ~ /^xrt/ { print $2 }') + sudo apt remove -y $packages sudo apt -y --fix-broken install + sudo apt install -y ocl-icd-libopencl1 dkms + sudo -E dpkg -i xrt_*-amd64-base.deb || true + sudo -E dpkg -i xrt_*-amd64-base-dev.deb || true + sudo -E dpkg -i xrt_plugin*-amdxdna.deb || true popd fi ######################################################### @@ -187,14 +146,14 @@ GROUP_ID=`id -g $USER_NAME` GROUP_NAME=`id -g -n $USER_NAME` ## Checks to make sure that all the required tarballs and license are in the directory -if [ ! -f "./pynqMLIR-AIE.tar.gz" ]; then +if [ ! -f "./build_tmp/pynqMLIR-AIE.tar.gz" ]; then echo "Error! pynqMLIR-AIE.tar.gz is missing, downloading from opendownloads..." wget -O $build_tmp/pynqMLIR-AIE.tar.gz $MLIR_FILE else cp pynqMLIR-AIE.tar.gz $build_tmp fi -if [ ! -f "./xilinx_tools.tar.gz" ]; then +if [ ! -f "./build_tmp/xilinx_tools.tar.gz" ]; then echo "xilinx_tools.tar.gz is missing, downloading it from opendownloads..." wget -O $build_tmp/riallto_installer.zip $RIALLTO_FILE pushd $build_tmp diff --git a/scripts/linux/xdna-driver-builder/Dockerfile b/scripts/linux/xdna-driver-builder/Dockerfile index 38dd4b2..9838dee 100644 --- a/scripts/linux/xdna-driver-builder/Dockerfile +++ b/scripts/linux/xdna-driver-builder/Dockerfile @@ -1,53 +1,41 @@ -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT FROM ubuntu:24.04 ARG DEBIAN_FRONTEND=noninteractive -ARG KERNEL_HEADERS -ARG KERNEL_HEADERS_GENERIC -ARG KERNEL_MODULES -ARG KERNEL_IMAGE +ENV XDNADRIVERCOMMITID 9a9045284620afdfa2682cde7dae133e25dcc335 RUN apt-get update -RUN apt-get install -y vim git -RUN apt-get install -y flex bison +RUN apt-get install -y --install-recommends linux-generic-hwe-24.04 +RUN apt-get install -y linux-headers-$(uname -r) +RUN apt-get install -y vim git flex bison make libelf1t64 +RUN apt-get install -y dpkg-dev libelf-dev zstd ocl-icd-libopencl1 +RUN apt-get install -y bc debhelper rsync kmod cpio libssl-dev:native dkms RUN git config --global http.postBuffer 157286400 -RUN apt-get install make -RUN apt-get install -y dpkg-dev -RUN apt-get install -y bc debhelper rsync kmod cpio libssl-dev:native -RUN apt-get install -y libelf-dev -RUN apt-get install -y zstd - -COPY _work /root/ - -RUN apt-get install -y libelf1t64 -RUN apt-get install -y kmod -RUN apt-get install -y linux-base - -RUN dpkg -i /root/$KERNEL_HEADERS -RUN dpkg -i /root/$KERNEL_HEADERS_GENERIC -RUN dpkg -i /root/$KERNEL_MODULES -RUN dpkg -i /root/$KERNEL_IMAGE +#RUN apt-get install -y linux-base RUN git config --global url."https://github.com/".insteadOf "git@github.com:" RUN cd /root && git clone https://github.com/amd/xdna-driver.git --recursive -RUN cd /root/xdna-driver && git checkout f60608b +RUN cd /root/xdna-driver && git checkout $XDNADRIVERCOMMITID RUN cd /root/xdna-driver && git submodule update --recursive RUN apt-get install -y cmake jq pkg-config wget libdrm-dev -RUN apt-get install -y python3-pip -RUN apt-get install -y ocl-icd-opencl-dev +RUN apt-get install -y python3-pip ocl-icd-opencl-dev +# Install XRT dependencies RUN /root/xdna-driver/xrt/src/runtime_src/tools/scripts/xrtdeps.sh -docker -RUN mkdir /root/debs +# Build XDNA Driver RUN cd /root/xdna-driver/build && ./build.sh -release RUN cd /root/xdna-driver/build && ./build.sh -package -RUN cd /root/xdna-driver/xrt/build && ./build.sh -noert +# Build XRT +RUN cd /root/xdna-driver/xrt/build && ./build.sh -npu -opt -RUN cp /root/xdna-driver/build/Release/xrt_plugin*.deb /root/debs/ -RUN cp /root/xdna-driver/xrt/build/Release/xrt*xrt.deb /root/debs/ +# Make a copy of the deb files +RUN mkdir /root/debs +RUN cp /root/xdna-driver/xrt/build/Release/*.deb /root/debs/ +RUN cp /root/xdna-driver/build/Release/*.deb /root/debs/ diff --git a/scripts/linux/xdna-driver-builder/build.sh b/scripts/linux/xdna-driver-builder/build.sh index 56ec679..e60ee2a 100755 --- a/scripts/linux/xdna-driver-builder/build.sh +++ b/scripts/linux/xdna-driver-builder/build.sh @@ -1,45 +1,26 @@ #!/bin/bash # -# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -KERNEL_VERSION="6.10-rc2" -KERNEL_VERSION_FULL="6.10.0-061000rc2" -BUILD_DATE="202406022333" - -KERNEL_HEADERS="linux-headers-${KERNEL_VERSION_FULL}_${KERNEL_VERSION_FULL}.${BUILD_DATE}_all.deb" -KERNEL_HEADERS_GENERIC="linux-headers-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" -KERNEL_MODULES="linux-modules-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" -KERNEL_IMAGE="linux-image-unsigned-${KERNEL_VERSION_FULL}-generic_${KERNEL_VERSION_FULL}.${BUILD_DATE}_amd64.deb" - -rm -rf _work -mkdir -p _work -wget -P _work https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_HEADERS_GENERIC -wget -P _work https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_HEADERS -wget -P _work https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_IMAGE -wget -P _work https://kernel.ubuntu.com/mainline/v$KERNEL_VERSION/amd64/$KERNEL_MODULES - # Build a container that creates the appropriate linux kernel version docker build \ - -t xdna_deb_builder:latest \ - --build-arg KERNEL_HEADERS=$KERNEL_HEADERS \ - --build-arg KERNEL_HEADERS_GENERIC=$KERNEL_HEADERS_GENERIC \ - --build-arg KERNEL_MODULES=$KERNEL_MODULES \ - --build-arg KERNEL_IMAGE=$KERNEL_IMAGE \ + -t npubase:latest \ ./ -docker kill xdna_deb_builder_container || true +docker kill npubase_build_container || true # Lauch an image with that container -docker run -dit --rm --name xdna_deb_builder_container \ +docker run -dit --rm --name npubase_build_container \ -v $(pwd):/workspace \ -w /workspace/ \ - xdna_deb_builder:latest \ + npubase:latest \ /bin/bash -docker exec xdna_deb_builder_container bash -c "tar -zcvf driver.tar.gz /root/debs && mv driver.tar.gz /workspace/ubuntu24.04_npu_drivers.tar.gz" +# Execute container to get the driver and plugin +docker exec npubase_build_container bash -c "tar -zcvf driver.tar.gz /root/debs && mv driver.tar.gz /workspace/ubuntu24.04_npu_drivers.tar.gz" ## cleanup -docker kill xdna_deb_builder_container || true -docker image rm --force xdna_deb_builder:latest +docker kill npubase_build_container || true +docker image rm --force npubase:latest \ No newline at end of file diff --git a/scripts/wsl/setup_env.sh b/scripts/wsl/setup_env.sh old mode 100644 new mode 100755 diff --git a/scripts/wsl/ubuntu_deps.sh b/scripts/wsl/ubuntu_deps.sh old mode 100644 new mode 100755