使用GPU谷歌云ML引擎进行慢速训练

时间:2018-03-08 09:09:45

标签: python tensorflow file-io google-cloud-ml bytesio

对不起,如果我的问题是如此倾倒,但我花了很多时间试图了解问题的原因,但我不能 所以这是

我在谷歌云ML上训练tacotron模型我之前已经在floyd hub上训练它并且它非常快,所以我配置我的项目能够在谷歌ML上运行

这是我对我的项目进行的主要更改

原始

with open(metadata_filename, encoding='utf-8') as f:
  self._metadata = [line.strip().split('|') for line in f]
  hours = sum((int(x[2]) for x in self._metadata)) * hparams.frame_shift_ms / (3600 * 1000)
  log('Loaded metadata for %d examples (%.2f hours)' % (len(self._metadata), hours))

我的配置

with file_io.FileIO(metadata_filename, 'r') as f:
     self._metadata = [line.strip().split('|') for line in f]
     hours = sum((int(x[2]) for x in self._metadata)) * hparams.frame_shift_ms / (3600 * 1000)
     log('Loaded metadata for %d examples (%.2f hours)' % (len(self._metadata), hours))

原始

def _get_next_example(self):
    '''Loads a single example (input, mel_target, linear_target, cost) from disk'''
    if self._offset >= len(self._metadata):
      self._offset = 0
      random.shuffle(self._metadata)
    meta = self._metadata[self._offset]
    self._offset += 1

    text = meta[3]
    if self._cmudict and random.random() < _p_cmudict:
      text = ' '.join([self._maybe_get_arpabet(word) for word in text.split(' ')])

    input_data = np.asarray(text_to_sequence(text, self._cleaner_names), dtype=np.int32)
    linear_target = np.load(os.path.join(self._datadir, meta[0]))
    mel_target = np.load(os.path.join(self._datadir, meta[1]))
    return (input_data, mel_target, linear_target, len(linear_target))

我的配置

 def _get_next_example(self):

    '''Loads a single example (input, mel_target, linear_target, cost) from disk'''
    if self._offset >= len(self._metadata):
        self._offset = 0
        random.shuffle(self._metadata)
    meta = self._metadata[self._offset]
    self._offset += 1

    text = meta[3]
    if self._cmudict and random.random() < _p_cmudict:
        text = ' '.join([self._maybe_get_arpabet(word) for word in text.split(' ')])

    input_data = np.asarray(text_to_sequence(text, self._cleaner_names), dtype=np.int32)
    f = BytesIO(file_io.read_file_to_string(
        os.path.join(self._datadir, meta[0]),binary_mode=True))
    linear_target = np.load(f)
    s = BytesIO(file_io.read_file_to_string(
        os.path.join(self._datadir, meta[1]),binary_mode = True))
    mel_target = np.load(s)
    return (input_data, mel_target, linear_target, len(linear_target))

这里有2个屏幕截图来显示差异 Google MLFLoydhub

这是我在谷歌ML中使用的训练命令我使用scale-tier = BASIC_GPU gcloud ml-engine jobs submit training "$JOB_NAME" --stream-logs --module-name trainier.train --package-path trainier --staging-bucket "$BUCKET_NAME" --region "us-central1" --scale-tier=basic-gpu --config ~/gp-master/config.yaml --runtime-version=1.4 -- --base_dir "$BASEE_DIR" --input "$TRAIN_DATA"

所以我的问题是我做了什么可能导致这种缓慢的阅读数据或谷歌云ML有问题我怀疑??

1 个答案:

答案 0 :(得分:3)

好吧我想通了我应该把tensorflow-gpu == 1.4放在所需的包中而不是tensorflow == 1.4 ^^

相关问题