From f45c8d5f6b0f6042f83a7c4bc7c53d68c41cbf66 Mon Sep 17 00:00:00 2001 From: abchoudh-amd Date: Wed, 1 Oct 2025 01:18:41 +0530 Subject: [PATCH] Bugfixes for test failure (#1106) - Bugfixes - Update test instructions using docker --- projects/rocprofiler-compute/README.md | 15 +++++--- .../docker/Dockerfile.customrocmtest | 38 +++++-------------- .../docker/docker-compose.customrocmtest.yml | 6 ++- .../src/rocprof_compute_base.py | 12 +++--- .../rocprof_compute_profile/profiler_base.py | 5 +-- .../profiler_rocprofiler_sdk.py | 2 +- 6 files changed, 33 insertions(+), 45 deletions(-) diff --git a/projects/rocprofiler-compute/README.md b/projects/rocprofiler-compute/README.md index 2ae20b7675..f85da172cf 100644 --- a/projects/rocprofiler-compute/README.md +++ b/projects/rocprofiler-compute/README.md @@ -30,28 +30,31 @@ Users may checkout `amd-staging` to preview upcoming features. ## Testing -Populate the empty variables in `Dockerfile.customrocmtest` based on latest CI build information. +Populate the variable in `docker/docker-compose.customrocmtest.yml`. +Populate the variable in `docker/Dockerfile.customrocmtest` based on latest ROCm CI build information. To quickly get the environment (bash shell) for building and testing, run the following commands: * `cd docker` -* `docker compose -f docker-compose.customrocmtest.yml up --force-recreate -d && docker attach docker-customrocmtest-1` +* If the docker image is not available on the machine, then build the image, otherwise skip this step: `docker compose -f docker-compose.customrocmtest.yml build` +* Launch the container, and check the name of the container: `docker compose -f docker-compose.customrocmtest.yml up --force-recreate -d ` +* Run bash shell on the launched container: `docker exec -it bash` +* If testing is done, kill the container: `docker container kill ` -Inside the docker container, clean, build and install the project with tests enabled: +Inside the docker container, clean, build, then install the project with tests enabled: ``` rm -rf build install && cmake -B build -D CMAKE_INSTALL_PREFIX=install -D ENABLE_TESTS=ON -D INSTALL_TESTS=ON -DENABLE_COVERAGE=ON -S . && cmake --build build --target install --parallel 8 ``` Note that per the above command, build assets will be stored under `build` directory and installed assets will be stored under `install` directory. -Then, to run the automated test suite, run the following command: +Then, to run the automated test suite, run the following commands: ``` +mkdir build ctest ``` For manual testing, you can find the executable at `install/bin/rocprof-compute` -NOTE: This Dockerfile uses `ubuntu 22.04` as the base operating system image - ## Standalone binary To create a standalone binary, run the following commands: diff --git a/projects/rocprofiler-compute/docker/Dockerfile.customrocmtest b/projects/rocprofiler-compute/docker/Dockerfile.customrocmtest index cf2270c697..47ec351559 100644 --- a/projects/rocprofiler-compute/docker/Dockerfile.customrocmtest +++ b/projects/rocprofiler-compute/docker/Dockerfile.customrocmtest @@ -1,5 +1,5 @@ # Use a base image -FROM ubuntu:22.04 +FROM # Set the working directory WORKDIR /app @@ -18,33 +18,15 @@ RUN locale-gen en_US.UTF-8 # Install Python 3.10 and pip RUN apt-get install -y python3.10 python3.10-venv python3.10-dev python3-pip libsqlite3-dev - -# Update pip -RUN apt remove -y python3-wheel -RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -RUN python3.10 get-pip.py -RUN python3.10 -m pip install --upgrade pip setuptools wheel - -# Set Python 3.10 as the default python3 -RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 - -# Remove blinker python package -RUN apt-get remove -y python3-blinker - -# Install rocm -# Define custom version -ARG DEB_FILE="" -ARG AMDGPU_BUILD="" -ARG ROCM_BUILD="" -RUN curl -O "https://artifactory-cdn.amd.com/artifactory/list/amdgpu-deb/${DEB_FILE}" -RUN apt-get install -y "./${DEB_FILE}" -RUN amdgpu-repo --amdgpu-build="${AMDGPU_BUILD}" --rocm-build="compute-rocm-dkms-no-npi-hipclang/${ROCM_BUILD}" -RUN DEBIAN_FRONTEND=noninteractive TZ="America/Toronto" amdgpu-install --yes --usecase=rocm +RUN python3.10 -m venv venv +ENV PATH="venv/bin:$PATH" +RUN python -m pip install --upgrade pip # Install any dependencies specified in requirements.txt +WORKDIR /app/projects/rocprofiler-compute +COPY projects/rocprofiler-compute/requirements.txt /app/projects/rocprofiler-compute/requirements.txt +COPY projects/rocprofiler-compute/requirements-test.txt /app/projects/rocprofiler-compute/requirements-test.txt +RUN python -m pip install -r requirements.txt -r requirements-test.txt + # Run interactive bash shell -CMD ["/bin/bash", "-c", "\ - cd /app/projects/rocprofiler-compute \ - && python3.10 -m pip install -r requirements.txt -r requirements-test.txt \ - && exec /bin/bash \ -"] +CMD ["/bin/bash"] diff --git a/projects/rocprofiler-compute/docker/docker-compose.customrocmtest.yml b/projects/rocprofiler-compute/docker/docker-compose.customrocmtest.yml index 8b2ce9c31a..41c2741323 100644 --- a/projects/rocprofiler-compute/docker/docker-compose.customrocmtest.yml +++ b/projects/rocprofiler-compute/docker/docker-compose.customrocmtest.yml @@ -1,8 +1,12 @@ services: - customrocmtest: # service name + rocprofiler-compute-: # service name build: context: ../../../ dockerfile: projects/rocprofiler-compute/docker/Dockerfile.customrocmtest + image: rocprofiler-compute- + # Forward some env vars + environment: + ROCR_VISIBLE_DEVICES: ${ROCR_VISIBLE_DEVICES} devices: - /dev/kfd - /dev/dri diff --git a/projects/rocprofiler-compute/src/rocprof_compute_base.py b/projects/rocprofiler-compute/src/rocprof_compute_base.py index 5eba6c46ce..275f29c367 100644 --- a/projects/rocprofiler-compute/src/rocprof_compute_base.py +++ b/projects/rocprofiler-compute/src/rocprof_compute_base.py @@ -372,12 +372,12 @@ class RocProfCompute: if not hasattr(self.__args, "name") or not self.__args.name: console_error("-n/--name is required") self.__args.path = str(Path(self.__args.path) / self.__args.name) - # Add node name to workload path - if self.__args.subpath == "node_name": - self.__args.path = str(Path(self.__args.path) / socket.gethostname()) - # Add gpu model name to workload path - elif self.__args.subpath == "gpu_model": - self.__args.path = str(Path(self.__args.path) / self.__mspec.gpu_model) + # Add node name to workload path + if self.__args.subpath == "node_name": + self.__args.path = str(Path(self.__args.path) / socket.gethostname()) + # OR, Add gpu model name to workload path + elif self.__args.subpath == "gpu_model": + self.__args.path = str(Path(self.__args.path) / self.__mspec.gpu_model) # Create workload directory if it does not exist p = Path(self.__args.path) diff --git a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py index f546d486a6..ee9719b001 100644 --- a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py +++ b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_base.py @@ -32,7 +32,6 @@ from abc import abstractmethod from pathlib import Path from typing import Any, Optional, Union -import numpy as np import pandas as pd import yaml @@ -466,7 +465,7 @@ class RocProfCompute_Base: console_debug(output) console_log("profiling", f"Current input file: {fname}") - options = self.get_profiler_options(fname, self._soc) + options = self.get_profiler_options(str(fname), self._soc) start_time = time.time() if self.__profiler == "rocprofv3" or self.__profiler == "rocprofiler-sdk": # Only 1-run case is permitted for attach/detach @@ -542,5 +541,5 @@ class RocProfCompute_Base: self._soc.post_profiling() -def test_df_column_equality(df: pd.DataFrame) -> np.bool: +def test_df_column_equality(df: pd.DataFrame) -> bool: return df.eq(df.iloc[:, 0], axis=0).all(1).all() diff --git a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprofiler_sdk.py b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprofiler_sdk.py index 103b076e6c..aa29be9e8c 100644 --- a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprofiler_sdk.py +++ b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprofiler_sdk.py @@ -70,7 +70,7 @@ class rocprofiler_sdk_profiler(RocProfCompute_Base): "ROCPROFILER_LIBRARY_CTOR": "1", "LD_PRELOAD": ":".join(ld_preload), "ROCP_TOOL_LIBRARIES": rocprofiler_sdk_tool_path, - "LD_LIBRARY_PATH": rocm_libdir, + "LD_LIBRARY_PATH": str(rocm_libdir), "ROCPROF_KERNEL_TRACE": "1", "ROCPROF_OUTPUT_FORMAT": args.format_rocprof_output, "ROCPROF_OUTPUT_PATH": f"{args.path}/out/pmc_1",