我正在使用TensorFlow-Slim。我的目标是在多GPU模式下运行给定的标准脚本(位于/models/slim/scripts中)。我已经测试了finetune_resnet_v1_50_on_flowers.sh脚本(在2017年4月12日克隆)。我刚刚在训练部分的末尾添加了--num_clones=2 (灵感来自/slim/deployment/model_Test.py和之前的StackOverflow答案):
python train_image_classifier.py \
--train_dir=${TRAIN_DIR} \
--dataset_name=flowers \
--dataset_split_name=train \
--dataset_dir=${DATASET_DIR} \
--model_name=resnet_v1_50 \
--checkpoint_path=${PRETRAINED_CHECKPOINT_DIR}/resnet_v1_50.ckpt \
--checkpoint_exclude_scopes=resnet_v1_50/logits \
--trainable_scopes=resnet_v1_50/logits \
--max_number_of_steps=3000 \
--batch_size=32 \
--learning_rate=0.01 \
--save_interval_secs=60 \
--save_summaries_secs=60 \
--log_every_n_steps=100 \
--optimizer=rmsprop \
--weight_decay=0.00004 \
--num_clones=2部署/model_deploy_test.py中的代码:
def testMultiGPU(self):
deploy_config = model_deploy.DeploymentConfig(num_clones=2)我有一个警告(‘忽略设备规范’):
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla P100-SXM2-16GB, pci bus id: 0000:85:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:1) -> (device: 1, name: Tesla P100-SXM2-16GB, pci bus id: 0000:86:00.0)
I tensorflow/core/common_runtime/simple_placer.cc:669] Ignoring device specification /GPU:1 for node 'clone_1/fifo_queue_Dequeue' because the input edge from 'prefetch_queue/fifo_queue' is a reference connection and already has a device field set to /CPU:0
I tensorflow/core/common_runtime/simple_placer.cc:669] Ignoring device specification /GPU:0 for node 'clone_0/fifo_queue_Dequeue' because the input edge from 'prefetch_queue/fifo_queue' is a reference connection and already has a device field set to /CPU:0GPU运行正常(内存使用率和GPU利用率),但与单个GPU训练相比,训练速度并不快。
此问题可能与:https://github.com/tensorflow/tensorflow/issues/8061有关
我将非常高兴收到您对这个问题的答案、意见或具体建议。
CUDA版本: 8.0版,V8.0.53版
从二进制文件安装的TensorFlow,测试版本: 1.0.1和1.1.0rc
图形处理器: NVIDIA Tesla P100 (SXM2)
发布于 2017-11-21 14:07:53
请遵循本文档https://github.com/tensorflow/tensorflow/issues/12689以确保变量存储在CPU中,我们需要在slim.arg_scope([slim.model_variable, slim.variable], device='/cpu:0'):中使用上下文管理器。
它解决了我的问题。
发布于 2017-05-31 06:42:15
即使这个答案可能会晚一点,训练也不应该更快(以秒为单位)。相反,创建了另一个模型,使用您的参数导致有效的批处理大小为64,因此您可以将最大步数减半。
https://stackoverflow.com/questions/43405358
复制相似问题