ROCm / rocprofiler

ROC profiler library. Profiling with perf-counters and derived metrics.
https://rocm.docs.amd.com/projects/rocprofiler/en/latest/
MIT License
128 stars 49 forks source link

rocprof bash sets PATH to the wrong location, then fails to find rocminfo #143

Closed JonChesterfield closed 3 weeks ago

JonChesterfield commented 4 months ago

Problem Description

The rocprof bash script installed under bin/rocprof sets path to export PATH=.:$PATH. I think this is intended to put the current directory on the path such that things like rocminfo can be found next to rocprof. That only works when running rocprof from the current directory.

/bin/sh: 1: rocminfo: not found
Traceback (most recent call last):
  File "/home/amd/rocm/aomp_19.0-2/libexec/rocprofiler/tblextr.py", line 1113, in <module>
    metadata_gen(sysinfo_file, "rocminfo")
  File "/home/amd/rocm/aomp_19.0-2/libexec/rocprofiler/tblextr.py", line 124, in metadata_gen
    raise Exception('Could not run command: "' + sysinfo_cmd + '"')
Exception: Could not run command: "rocminfo"

If this is changed to something like export PATH=$BIN_DIR:$PATH then rocprof successfully finds rocminfo.

Related, there's a error message that is intended to print when rocminfo is not found, instead of the above trace:

if !command -v rocminfo > /dev/null 2>&1 ;  then
  error "'rocminfo' utility is not found: please add ROCM bin path to PATH env var.";
fi

I don't believe that works as intended, adding parens would be one way to retrieve the nicer message

if !(command -v rocminfo > /dev/null 2>&1) ;  then
  error "'rocminfo' utility is not found: please add ROCM bin path to PATH env var.";
fi

Operating System

Ubuntu

CPU

2990WX

GPU

AMD Radeon VII

ROCm Version

ROCm 6.1.0

ROCm Component

rocprofiler

Steps to Reproduce

Change to a directory other than the one containing rocprof. Run rocprof. Note the stack trace from python.

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

harkgill-amd commented 2 months ago

Hi @JonChesterfield, are you still experiencing this issue with ROCm 6.2.0? I was not able to reproduce this following the steps you provided. From my understanding, when calling rocminfo or rocprof, the executable/script are found under /usr/bin which should be under your PATH. These files are symbolically linked to those found in /opt/rocm-6.2.0/bin and you should be able to call them regardless of which directory you are in.

export PATH=.:$PATH simply appends the current directory to PATH, the existing directories on PATH will still be checked, in this case /usr/bin.

harkgill-amd commented 3 weeks ago

Closing this issue out. If you are still encountering errors when calling rocminfo, please leave a comment and I'll re-open this ticket. Thanks!