在用slim中的train_image_classifier.py调用tfrecord数据进行分类时
python /train_image_classifier.py--train_dir=model --dataset_name=myimages --dataset_split_name=train--dataset_dir=/slim/images --batch_size=10--max_number_of_steps=10000 --model_name=inception_v3
报了下面的错误:
InvalidArgumentError
(see above for traceback): Cannot assign a device for operation
'gradients/InceptionV3/Logits/Dropout_1b/dropout/div_grad/BroadcastGradientArgs':Operation was explicitly assigned to /device:GPU:0 but available devices are [
/job:localhost/replica:0/task:0/device:CPU:0 ].Make sure the device specification refers to a valid device. [[Node:gradients/InceptionV3/Logits/Dropout_1b/dropout/div_grad/BroadcastGradientArgs= BroadcastGradientArgs[T=DT_INT32,_device="/device:GPU:0"](gradients/InceptionV3/Logits/Dropout_1b/dropout/div_grad/Shape,gradients/InceptionV3/Logits/Dropout_1b/dropout/div_grad/Shape_1)]]
大概意思是程序中指定使用GPU设备运行,但电脑没有GPU只有CPU,参考修改
http://blog.csdn.net/u010164190/article/details/78149049
将train_image_classifier.py中的
tf.app.Flags.DEFINE_boolean('clone_on_cpu',False,'use CPUs to deploy clones.')
改为:
tf.app.Flags.DEFINE_boolean('clone_on_cpu',True,'use
CPUs to deploy clones.')
另查看:
http://wiki.jikexueyuan.com/project/tensorflow-zh/how_tos/using_gpu.html
另外有一个警告:
YourCPU supports instructions that this TensorFlow binary was not compiled to use:SSE4.2 AVX AVX2 FMA
产生该问题的原因是你的CPU是支持的,但tensorflow没有按照支持AVX、AVX2、FMA......编译造成的。
解决办法:
开头加上
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
参见:http://bbs.csdn.net/topics/392284025