Subversion Repositories ALCASAR

Rev

Rev 2976 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
Line 41... Line 41...
41
            }
41
            }
42
 
42
 
43
            $this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
43
            $this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
44
            break;
44
            break;
45
        case 'data':
45
        case 'data':
46
            if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/nvidiasmi.txt', $lines)) {
46
            if (CommonFunctions::rftsdata('nvidiasmi.tmp', $lines)) {
47
                $this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
47
                $this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
48
            }
48
            }
49
            break;
49
            break;
50
        default:
50
        default:
51
            $this->error->addConfigError('__construct()', '[sensor_nvidiasmi] ACCESS');
51
            $this->error->addConfigError('__construct()', '[sensor_nvidiasmi] ACCESS');
52
            break;
-
 
53
        }
52
        }
54
    }
53
    }
55
 
54
 
56
    /**
55
    /**
57
     * get the information
56
     * get the information
58
     *
57
     *
59
     * @see PSI_Interface_Sensor::build()
58
     * @see PSI_Interface_Sensor::build()
60
     *
59
     *
61
     * @return Void
60
     * @return void
62
     */
61
     */
63
    public function build()
62
    public function build()
64
    {
63
    {
65
        $gpuc=count($this->_gpus);
64
        $gpuc=count($this->_gpus);
66
        switch ($gpuc) {
65
        switch ($gpuc) {
67
            case 0:
66
        case 0:
68
                $this->error->addError("nvidia-smi", "No values");
67
            $this->error->addError("nvidia-smi", "No values");
69
                break;
68
            break;
70
            case 1:
69
        case 1:
71
                $this->error->addError("nvidia-smi", "Error: ".$this->_gpus[0]);
70
            $this->error->addError("nvidia-smi", "Error: ".$this->_gpus[0]);
72
                break;
71
            break;
73
            default:
72
        default:
74
                for ($c = 0; $c < $gpuc; $c++) {
73
            for ($c = 0; $c < $gpuc; $c++) {
75
                    if (preg_match("/^\s+GPU Current Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
74
                if (preg_match("/^\s+GPU Current Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
76
                        $dev = new SensorDevice();
75
                    $dev = new SensorDevice();
77
                        $dev->setName("GPU ".($c)." (nvidiasmi)");
76
                    $dev->setName("GPU ".($c)." (nvidiasmi)");
78
                        $dev->setValue($out[1]);
77
                    $dev->setValue($out[1]);
79
                        if (preg_match("/^\s+GPU Shutdown Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
78
                    if (preg_match("/^\s+GPU Shutdown Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
80
                            $dev->setMax($out[1]);
-
 
81
                        }
-
 
82
                        $this->mbinfo->setMbTemp($dev);
-
 
83
                    }
-
 
84
                    if (preg_match("/^\s+Power Draw\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
-
 
85
                        $dev = new SensorDevice();
-
 
86
                        $dev->setName("GPU ".($c)." (nvidiasmi)");
-
 
87
                        $dev->setValue($out[1]);
-
 
88
                        if (preg_match("/^\s+Power Limit\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
-
 
89
                            $dev->setMax($out[1]);
79
                        $dev->setMax($out[1]);
90
                        }
-
 
91
                        $this->mbinfo->setMbPower($dev);
-
 
92
                    }
-
 
93
                    if (preg_match("/^\s+Fan Speed\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
94
                        $dev = new SensorDevice();
-
 
95
                        $dev->setName("GPU ".($c)." (nvidiasmi)");
-
 
96
                        $dev->setValue($out[1]);
-
 
97
                        $dev->setUnit("%");
-
 
98
                        $this->mbinfo->setMbFan($dev);
-
 
99
                    }
-
 
100
                    if (preg_match("/^\s+Performance State\s+:\s*(\S+)\s*$/m", $this->_gpus[$c], $out)) {
-
 
101
                        $dev = new SensorDevice();
-
 
102
                        $dev->setName("GPU ".($c)." Performance State (nvidiasmi)");
-
 
103
                        $dev->setValue($out[1]);
-
 
104
                        $this->mbinfo->setMbOther($dev);
-
 
105
                    }
-
 
106
                    if (preg_match("/^\s+Gpu\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
107
                        $dev = new SensorDevice();
-
 
108
                        $dev->setName("GPU ".($c)." Utilization (nvidiasmi)");
-
 
109
                        $dev->setValue($out[1]);
-
 
110
                        $dev->setUnit("%");
-
 
111
                        $this->mbinfo->setMbOther($dev);
-
 
112
                    }
-
 
113
                    if (preg_match("/^\s+Memory\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
114
                        $dev = new SensorDevice();
-
 
115
                        $dev->setName("GPU ".($c)." Memory Utilization (nvidiasmi)");
-
 
116
                        $dev->setValue($out[1]);
-
 
117
                        $dev->setUnit("%");
-
 
118
                        $this->mbinfo->setMbOther($dev);
-
 
119
                    }
-
 
120
                    if (preg_match("/^\s+Encoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
121
                        $dev = new SensorDevice();
-
 
122
                        $dev->setName("GPU ".($c)." Encoder Utilization (nvidiasmi)");
-
 
123
                        $dev->setValue($out[1]);
-
 
124
                        $dev->setUnit("%");
-
 
125
                        $this->mbinfo->setMbOther($dev);
-
 
126
                    }
80
                    }
-
 
81
                    $this->mbinfo->setMbTemp($dev);
-
 
82
                }
127
                    if (preg_match("/^\s+Decoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
83
                if (preg_match("/^\s+Power Draw\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
128
                        $dev = new SensorDevice();
84
                    $dev = new SensorDevice();
129
                        $dev->setName("GPU ".($c)." Decoder Utilization (nvidiasmi)");
85
                    $dev->setName("GPU ".($c)." (nvidiasmi)");
130
                        $dev->setValue($out[1]);
86
                    $dev->setValue($out[1]);
131
                        $dev->setUnit("%");
87
                    if (preg_match("/^\s+Power Limit\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
132
                        $this->mbinfo->setMbOther($dev);
88
                        $dev->setMax($out[1]);
133
                    }
89
                    }
-
 
90
                    $this->mbinfo->setMbPower($dev);
-
 
91
                }
-
 
92
                if (preg_match("/^\s+Fan Speed\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
93
                    $dev = new SensorDevice();
-
 
94
                    $dev->setName("GPU ".($c)." (nvidiasmi)");
-
 
95
                    $dev->setValue($out[1]);
-
 
96
                    $dev->setUnit("%");
-
 
97
                    $this->mbinfo->setMbFan($dev);
-
 
98
                }
-
 
99
                if (preg_match("/^\s+Performance State\s+:\s*(\S+)\s*$/m", $this->_gpus[$c], $out)) {
-
 
100
                    $dev = new SensorDevice();
-
 
101
                    $dev->setName("GPU ".($c)." Performance State (nvidiasmi)");
-
 
102
                    $dev->setValue($out[1]);
-
 
103
                    $this->mbinfo->setMbOther($dev);
-
 
104
                }
-
 
105
                if (preg_match("/^\s+Gpu\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
106
                    $dev = new SensorDevice();
-
 
107
                    $dev->setName("GPU ".($c)." Utilization (nvidiasmi)");
-
 
108
                    $dev->setValue($out[1]);
-
 
109
                    $dev->setUnit("%");
-
 
110
                    $this->mbinfo->setMbOther($dev);
134
                }
111
                }
-
 
112
                if (preg_match("/^\s+Memory\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
113
                    $dev = new SensorDevice();
-
 
114
                    $dev->setName("GPU ".($c)." Memory Utilization (nvidiasmi)");
-
 
115
                    $dev->setValue($out[1]);
-
 
116
                    $dev->setUnit("%");
-
 
117
                    $this->mbinfo->setMbOther($dev);
135
                break;
118
                }
-
 
119
                if (preg_match("/^\s+Encoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
120
                    $dev = new SensorDevice();
-
 
121
                    $dev->setName("GPU ".($c)." Encoder Utilization (nvidiasmi)");
-
 
122
                    $dev->setValue($out[1]);
-
 
123
                    $dev->setUnit("%");
-
 
124
                    $this->mbinfo->setMbOther($dev);
-
 
125
                }
-
 
126
                if (preg_match("/^\s+Decoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
-
 
127
                    $dev = new SensorDevice();
-
 
128
                    $dev->setName("GPU ".($c)." Decoder Utilization (nvidiasmi)");
-
 
129
                    $dev->setValue($out[1]);
-
 
130
                    $dev->setUnit("%");
-
 
131
                    $this->mbinfo->setMbOther($dev);
-
 
132
                }
-
 
133
            }
136
        }
134
        }
137
    }
135
    }
138
}
136
}