简体   繁体   English

Tensorflow 不想使用 GPU

[英]Tensorflow doesn't want to use GPU

I want to train "standford chatbot" from here https://github.com/chiphuyen/stanford-tensorflow-tutorials/tree/master/assignments/chatbot on GPU, but it doesn't use my GPU, but all need libraries (CuNN, CUDA, tensorflow-gpu etc.) are installed I tried:我想从这里https://github.com/chiphuyen/stanford-tensorflow-tutorials/tree/master/assignments/chatbot在 GPU 上训练“standford chatbot”,但它不使用我的 GPU,但都需要库(安装了 CuNN、CUDA、tensorflow-gpu 等)我试过:

def train():
""" Train the bot """

test_buckets, data_buckets, train_buckets_scale = _get_buckets()
# in train mode, we need to create the backward path, so forwrad_only is False

model = ChatBotModel(False, config.BATCH_SIZE)
model.build_graph()

saver = tf.train.Saver(var_list=tf.trainable_variables())

with tf.Session(config=tf.ConfigProto(allow_soft_placement=True,log_device_placement=True)) as sess:
    print('Start training')

    sess.run(tf.global_variables_initializer())
    _check_restore_parameters(sess, saver)

    iteration = model.global_step.eval()
    total_loss = 0
    while True:

        skip_step = _get_skip_step(iteration)
        bucket_id = _get_random_bucket(train_buckets_scale)
        encoder_inputs, decoder_inputs, decoder_masks = data.get_batch(data_buckets[bucket_id], 
                                                                       bucket_id,
                                                                       batch_size=config.BATCH_SIZE)
        start = time.time()
        _, step_loss, _ = run_step(sess, model, encoder_inputs, decoder_inputs, decoder_masks, bucket_id, False)
        total_loss += step_loss
        iteration += 1

        if iteration % skip_step == 0:
            print('Итерация {}: потеря {}, время {}'.format(iteration, total_loss/skip_step, time.time() - start))
            start = time.time()
            total_loss = 0
            saver.save(sess, os.path.join(config.CPT_PATH, 'chatbot'), global_step=model.global_step)
            if iteration % (10 * skip_step) == 0:
                # Run evals on development set and print their loss
                _eval_test_set(sess, model, test_buckets)
                start = time.time()
            sys.stdout.flush()

But It always show:但它总是显示:

InvalidArgumentError (see above for traceback): Cannot assign a device to node 'save/Const': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.

Colocation Debug Info: Colocation group had the following types and devices: Const: CPU Identity: CPU [[Node: save/Const = Constdtype=DT_STRING, value=Tensor, _device="/device:GPU:0"]]托管调试信息:托管组有以下类型和设备: Const:CPU 标识:CPU [[Node: save/Const = Constdtype=DT_STRING, value=Tensor, _device="/device:GPU:0"]]

Are there some configuration file for tensorflow where I can specify to use only GPU or some another way (i tried "with tf.device("/gpu:0"):" and device_count={'GPU': 1}) )是否有一些 tensorflow 的配置文件,我可以在其中指定仅使用 GPU 或其他方式(我尝试了“with tf.device("/gpu:0"):" 和 device_count={'GPU': 1}) )

From your error:从你的错误:

Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.无法满足显式设备规范“/device:GPU:0”,因为没有支持 GPU 设备的内核可用。

That means that the 'save/Const' operation cannot be forcefully assigned to a GPU via with tf.device(): because there is no GPU implementation for it.这意味着不能通过with tf.device():'save/Const'操作强制分配给 GPU with tf.device():因为它没有 GPU 实现。 Remove the with tf.device(): part (or put that operation outside of it) and let TF decide where to put operations (it will prefer GPU over CPU anyhow)删除with tf.device():部分(或将该操作放在它之外)并让 TF 决定将操作放在哪里(无论如何它会更喜欢 GPU 而不是 CPU)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM