示例#1
0
    def do_monitor(self, data_list):
        for data in data_list:
            if 'gpu' in data['tags'].keys():
                device_name = data['measurement']
                amd_gpu_temperature = data['fields']['temperature']

                if amd_gpu_temperature > HEAT_LIMIT:
                    LOG.error(
                        'Current temperature of AMD GPU-%s is %d > %d! Killing all miners...',
                        device_name, amd_gpu_temperature, HEAT_LIMIT)
                    self.switch_off_miner_overheat(SLEEP_TIMEOUT_MINS)
示例#2
0
    def do_monitor(self, data_list):
        for data in data_list:
            device_name = data['measurement']
            temperature = int(data['fields']['temperature'])
            power_usage = int(data['fields']['power_usage'])

            if temperature > HEAT_LIMIT:
                LOG.error(
                    'Current temperature of Nvidia GPU-%s is %d > %d! Killing all miners...',
                    device_name, temperature, HEAT_LIMIT)
                self.switch_off_miner_overheat(HEATAGE_SLEEP_TIMEOUT_MINS)

            if power_usage < POWER_LIMIT:
                LOG.error(
                    'Current power usage from Nvidia GPU-%s is %d < %d! Killing all miners...',
                    device_name, power_usage, POWER_LIMIT)
                self.switch_off_miner_underpowered(WATTAGE_SLEEP_TIMEOUT_MINS)
示例#3
0
    def _receive_frame_info(self, fd):
        client_socket = self.__fd_to_socket[fd]

        header = client_socket.recv(4, socket.MSG_WAITALL)
        LOG.info("the length of header is {}, header:{}", len(header), header)

        if len(header) != 4:
            LOG.error('header length is not 4')
            return None

        data_length = struct.unpack('i', header)[0]
        data_bin = client_socket.recv(data_length, socket.MSG_WAITALL)
        if len(data_bin) != data_length:
            LOG.error('the length of dataBin is not equal to data length')
            return None

        # 前面16个字节是魔数、补偿信息、是否终止、帧序号,后面是帧数据
        magic_number, reward, terminal, frame_index = struct.unpack(
            'ifii', data_bin[0:16])
        if magic_number != MAGIC_NUMBER:
            LOG.error('magic number error')
            return None

        np_array = np.fromstring(data_bin[16:], np.uint8)
        image = np.reshape(np_array, (IMAGE_WIDTH, IMAGE_HEIGHT))
        done = bool(terminal == 1)
        LOG.debug(
            'receive frame information from fd {}: frame index = {}, reward = {}'
            .format(client_socket.fileno(), frame_index, reward))
        return image, reward, done, frame_index
示例#4
0
    def _load_server_config(self):
        current_path = os.path.abspath(
            os.path.dirname(os.path.dirname(__file__)))
        config_path = os.path.join(current_path, SERVER_CONFIG_FILE)
        LOG.info("the config path of server is {}, current_path:{}".format(
            config_path, current_path))

        if os.path.exists(config_path):
            server_config = configparser.ConfigParser()
            server_config.read(config_path)
        else:
            LOG.error('Config File not exist in {0}'.format(config_path))
            return False

        # 从配置文件中读取IP和端口
        self.server_ip = server_config.get('SERVER', 'IP', fallback='0.0.0.0')
        self.server_port = server_config.getint('SERVER',
                                                'Port',
                                                fallback=8888)
        LOG.info("the server info as list, ip:{}, port:{}".format(
            self.server_ip, self.server_port))
        return True