ROCm / rocminfo

ROCm Application for Reporting System Info
Other
35 stars 32 forks source link

Fix invalid escape sequence deprecation in Python3 #55

Closed getianao closed 10 months ago

getianao commented 2 years ago

Now rocm_agent_enumerator will raise warnings when meeting unrecognized escape sequences in some versions of Python3.

$ rocm_agent_enumerator
/mnt/sdb1/public/yum/env/v1/spack/opt/spack/linux-centos7-zen/gcc-8.5.0/rocminfo-4.3.1-7fnsjl2k2vvivl6bbda6m2sjtxlyawg2/bin/rocm_agent_enumerator:88: DeprecationWarning: invalid escape sequence \A
  line_search_term = re.compile("\A\s+Name:\s+(gfx\d+)")
/mnt/sdb1/public/yum/env/v1/spack/opt/spack/linux-centos7-zen/gcc-8.5.0/rocminfo-4.3.1-7fnsjl2k2vvivl6bbda6m2sjtxlyawg2/bin/rocm_agent_enumerator:106: DeprecationWarning: invalid escape sequence \w
  target_search_term = re.compile("1002:\w+")
gfx000
gfx908
gfx908
$ python3 --version
Python 3.8.12

This fix uses raw strings to ensure Python not to escape the backslash.

trixirt commented 11 months ago

This will become a general problem in the next release on Fedora because rawhide has moved to python 3.12 These warning pollute the use of tools that use rocm_agent_enumerator

$ hipcc --version /usr/bin/rocm_agent_enumerator:95: SyntaxWarning: invalid escape sequence '\w' @staticVars(search_name=re.compile("gfx[0-9a-fA-F]+(:[-+:\w]+)?")) /usr/bin/rocm_agent_enumerator:152: SyntaxWarning: invalid escape sequence '\A' line_search_term = re.compile("\A\s+Name:\s+(amdgcn-amd-amdhsa--gfx\d+)") /usr/bin/rocm_agent_enumerator:154: SyntaxWarning: invalid escape sequence '\A' line_search_term = re.compile("\A\s+Name:\s+(gfx\d+)") /usr/bin/rocm_agent_enumerator:175: SyntaxWarning: invalid escape sequence '\w' target_search_term = re.compile("1002:\w+") HIP version: 5.7.31921- clang version 17.0.4 (Fedora 17.0.4-1.fc40) Target: x86_64-redhat-linux-gnu Thread model: posix InstalledDir: /usr/bin

dayatsin-amd commented 10 months ago

Thank you @getianao patch will be submitted internally and will be part of ROCm 6.1