(self, stats_config)
Use nvidia smi command line tool to collect metrics
        :param stats_config:
        :return:
Use nvidia smi command line tool to collect metrics
        :param stats_config:
        :return:
Use nvidia smi command line tool to collect metrics : param stats_config : : return :
def collect_via_nvidia_smi(self, stats_config):
        """
        Use nvidia smi command line tool to collect metrics
        :param stats_config:
        :return:
        """
        raw_output = self.run_command([
            '--query-gpu={query_gpu}'.format(query_gpu=','.join(stats_config)),
            '--format=csv,nounits,noheader'
        ])

        if raw_output is None:
            return

        results = raw_output[0].strip().split("\n")
        for result in results:
            stats = result.strip().split(',')
            assert len(stats) == len(stats_config)
            index = stats[0]
            for stat_name, metric in izip(stats_config[1:], stats[1:]):
                metric_name = 'gpu_{index}.{stat_name}'.format(
                    index=str(index),
                    stat_name=stat_name
                )
                self.publish(metric_name, metric)
def collect_via_nvidia_smi ( self , stats_config ) : raw_output = self . run_command ( [ '--query-gpu={query_gpu}' . format ( query_gpu = ',' . join ( stats_config ) ) , '--format=csv,nounits,noheader' ] ) if raw_output is None : return results = raw_output [ 0 ] . strip ( ) . split ( "\n" ) for result in results : stats = result . strip ( ) . split ( ',' ) assert len ( stats ) == len ( stats_config ) index = stats [ 0 ] for stat_name , metric in izip ( stats_config [ 1 : ] , stats [ 1 : ] ) : metric_name = 'gpu_{index}.{stat_name}' . format ( index = str ( index ) , stat_name = stat_name ) self . publish ( metric_name , metric )