ROCm / ROC-smi

ROC System Management Interface
https://github.com/RadeonOpenCompute/ROC-smi/blob/master/README.md
177 stars 56 forks source link

'SyntaxWarning: "is" with a literal. Did you mean "=="?' warning in rocm-smi output #78

Closed DerVerruckteFuchs closed 4 years ago

DerVerruckteFuchs commented 4 years ago

Whenever I use rocm-smi I get warning output before any other output with Python 3.8:

% python3.8 ./rocm_smi.py                                                                                                                                                                                       ~/rocm-smi/ROC-smi-roc-2.9.0
./rocm_smi.py:720: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clocktype is 'freq':
./rocm_smi.py:805: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:827: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (retiredType is 'all' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:1385: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:1752: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ptype is 'R':
./rocm_smi.py:1754: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif ptype is 'P':
./rocm_smi.py:2200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clkType is 'sclk':
./rocm_smi.py:2202: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif clkType is 'mclk':

========================ROCm System Management Interface========================
================================================================================
GPU  Temp   AvgPwr  SCLK    MCLK    Fan     Perf  PwrCap  VRAM%  GPU%  
1    45.0c  19.0W   852Mhz  945Mhz  26.67%  auto  220.0W   20%   11%   
================================================================================
==============================End of ROCm SMI Log ==============================

I get normal output as expected with Python 2.7:

% python2.7 ./rocm_smi.py                                                                                                                                                                                       ~/rocm-smi/ROC-smi-roc-2.9.0

========================ROCm System Management Interface========================
================================================================================
GPU  Temp   AvgPwr  SCLK    MCLK    Fan     Perf  PwrCap  VRAM%  GPU%  
1    42.0c  19.0W   852Mhz  945Mhz  26.67%  auto  220.0W   20%   6%    
================================================================================
==============================End of ROCm SMI Log ==============================

However, with both Python 3.8 and 2.7 I get similar warning output when trying to set my fan speeds.

2.7:

% python2.7 ./rocm_smi.py --setfan 40%                                                                                                                                                                          ~/rocm-smi/ROC-smi-roc-2.9.0
./rocm_smi.py:720: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clocktype is 'freq':
./rocm_smi.py:805: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:827: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (retiredType is 'all' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:1385: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:1752: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ptype is 'R':
./rocm_smi.py:1754: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif ptype is 'P':
./rocm_smi.py:2200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clkType is 'sclk':
./rocm_smi.py:2202: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif clkType is 'mclk':

========================ROCm System Management Interface========================
GPU[1]      : Successfully set fan speed to Level 102
==============================End of ROCm SMI Log ==============================

3.8 notably has more output:

% python3.8 ./rocm_smi.py --setfan 40%                                                                                                                                                                          ~/rocm-smi/ROC-smi-roc-2.9.0
./rocm_smi.py:720: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clocktype is 'freq':
./rocm_smi.py:805: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:827: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (retiredType is 'all' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:1385: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:1752: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ptype is 'R':
./rocm_smi.py:1754: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif ptype is 'P':
./rocm_smi.py:2200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clkType is 'sclk':
./rocm_smi.py:2202: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif clkType is 'mclk':
./rocm_smi.py:720: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clocktype is 'freq':
./rocm_smi.py:805: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:827: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (retiredType is 'all' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:1385: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:1752: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ptype is 'R':
./rocm_smi.py:1754: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif ptype is 'P':
./rocm_smi.py:2200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clkType is 'sclk':
./rocm_smi.py:2202: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif clkType is 'mclk':

========================ROCm System Management Interface========================
GPU[1]      : Successfully set fan speed to Level 102
==============================End of ROCm SMI Log ==============================

Using sudo reduces output for 3.8 (looks similar to setting fan with Python 2.7 without sudo):

% sudo python3.8 ./rocm_smi.py --setfan 40%                                                                                                                                                                     ~/rocm-smi/ROC-smi-roc-2.9.0
./rocm_smi.py:720: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clocktype is 'freq':
./rocm_smi.py:805: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:827: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if (retiredType is 'all' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:828: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'retired' and pgType is 'R' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:829: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'pending' and pgType is 'P' or \
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:830: SyntaxWarning: "is" with a literal. Did you mean "=="?
  retiredType is 'unreservable' and pgType is 'F'):
./rocm_smi.py:1385: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if component is 'driver':
./rocm_smi.py:1752: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if ptype is 'R':
./rocm_smi.py:1754: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif ptype is 'P':
./rocm_smi.py:2200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if clkType is 'sclk':
./rocm_smi.py:2202: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif clkType is 'mclk':

========================ROCm System Management Interface========================
GPU[1]      : Successfully set fan speed to Level 102
==============================End of ROCm SMI Log ==============================

Using sudo with 2.7 eliminates warnings completely:

% sudo python2.7 ./rocm_smi.py --setfan 40%                                                                                                                                                                     ~/rocm-smi/ROC-smi-roc-2.9.0

========================ROCm System Management Interface========================
GPU[1]      : Successfully set fan speed to Level 102
==============================End of ROCm SMI Log ==============================
rigred commented 4 years ago

This is just a python2 vs python3 change. Rocm-smi should best possible be updated to Python3 as many distros are moving rapidly towards removing python2 from the default install base.

All you have to do for now is change the following in rocm_smi.py

-- !/usr/bin/env python
++ !/usr/bin/env python2
piec commented 4 years ago

I made a PR to deal with that a few days ago https://github.com/RadeonOpenCompute/ROC-smi/pull/80 Cheers

kentrussell commented 4 years ago

I've brought the fix internally. Sorry that it's taken 6 months to get this brought in. I'm working on some changes to ensure that PRs aren't outstanding this long going forward.

kentrussell commented 4 years ago

Fixed in 3.6