在学习tensorflow的分布式学习时,在实验代码中遇到以下错误:

InternalError: Blas GEMM launch failed : a.shape=(100, 784), b.shape=(784, 10), m=100, n=10...

查看了几种解决方案:https://blog.csdn.net/Vinsuan1993/article/details/81142855 ,都不work,电脑重启后仍然出错。

最后通过做如下修改,错误解决,然后再将代码改回去,错误未复现。

IMAGE_PIXELS = 28
# x = tf.placeholder(dtype=tf.float32, shape=[None, IMAGE_PIXELS * IMAGE_PIXELS])
x = tf.placeholder(dtype=tf.float32, shape=[None, 784])## hid_w = tf.Variable(tf.truncated_normal([IMAGE_PIXELS * IMAGE_PIXELS, ##HIDDEN_UNITS],stddev=1.0 / IMAGE_PIXELS), name='hid_w')
hid_w = tf.Variable(tf.truncated_normal([784, HIDDEN_UNITS],stddev=1.0 / IMAGE_PIXELS), name='hid_w')

我知道这种办法有点SB,但是病急乱投医下管用了,也不知道为什么。这篇博客主要记录下自己当时碰到这个问题是怎么解决的,避免忘记,大家勿喷。

最后附实验源码:

"""
python single_device_single_gpu_mnist.py --job_name=ps --task_index=0
python single_device_single_gpu_mnist.py --job_name=worker --task_index=0
python single_device_single_gpu_mnist.py --job_name=worker --task_index=1
"""
# encoding:utf-8
import math
import tempfile
import time
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import osflags = tf.app.flags
flags.DEFINE_string('job_name', None, 'job name: worker or ps')
flags.DEFINE_integer('task_index', None, 'Index of task within the job')
flags.DEFINE_string('gpu_available', "0,1", 'gpu_available')
flags.DEFINE_integer("issync", None, "是否采用分布式的同步模式,1表示同步模式,0表示异步模式")
FLAGS = flags.FLAGSos.environ["CUDA_DEVICES_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = FLAGS.gpu_available##选择服务器:
cluster = tf.train.ClusterSpec({'ps': ["101.6.66.3:22221"],'worker': ["101.6.66.3:22225"]})# 定义超参数
IMAGE_PIXELS = 28
DATA_DIR = "./mnist"
HIDDEN_UNITS=100
TRAIN_STEPS = 10000
BATCH_SIZE=100
LR=0.01## 获取数据集
mnist = input_data.read_data_sets(DATA_DIR, one_hot=True)
##判断终端输入的正误
if FLAGS.job_name not in ["worker","ps"]:raise ValueError("--------FLAGS.job_name input error,must be 'worker' or 'ps'")
if FLAGS.task_index not in range(0,2):raise ValueError("--------FLAGS.task_index input error, must be an int")
## 根据终端输入,选择服务器
server = tf.train.Server(cluster,job_name=FLAGS.job_name,task_index=FLAGS.task_index)if FLAGS.job_name == "ps":server.join()## 训练代码
is_chief = (FLAGS.task_index == 0)
target = server.target
worker_device = "/job:worker/task:{}".format(FLAGS.task_index)
ps_device = "/job:ps/task:0/device:CPU:0"with tf.device(tf.train.replica_device_setter(worker_device=worker_device,ps_device = ps_device,cluster=cluster)):x = tf.placeholder(dtype=tf.float32, shape=[None, IMAGE_PIXELS * IMAGE_PIXELS])y_ = tf.placeholder(dtype=tf.float32, shape=[None, 10])global_step = tf.Variable(0, name='global_step', trainable=False)  # 创建纪录全局训练步数变量## variableshid_w = tf.Variable(tf.truncated_normal([IMAGE_PIXELS * IMAGE_PIXELS, HIDDEN_UNITS],stddev=1.0 / IMAGE_PIXELS), name='hid_w')hid_b = tf.Variable(tf.zeros([100]), name='hid_b')sm_w = tf.Variable(tf.truncated_normal([HIDDEN_UNITS, 10],stddev=1.0 / math.sqrt(HIDDEN_UNITS)), name='sm_w')sm_b = tf.Variable(tf.zeros([10]), name='sm_b')## opshid_lin = tf.nn.xw_plus_b(x, hid_w, hid_b)hid = tf.nn.relu(hid_lin)y = tf.nn.softmax(tf.nn.xw_plus_b(hid, sm_w, sm_b))cross_entropy = -tf.reduce_sum(y_ * tf.log(tf.clip_by_value(y, 1e-10, 1.0)))opt = tf.train.AdamOptimizer(LR)train_step = opt.minimize(cross_entropy, global_step=global_step)##创建sess,执行训练config = tf.ConfigProto()config.gpu_options.allow_growth = Trueconfig.log_device_placement = Truewith tf.Session(target,config=config) as sess:sess.run(tf.global_variables_initializer())print("worker {} : session initialization complete.".format(FLAGS.task_index))batch_xs, batch_ys = mnist.train.next_batch(BATCH_SIZE)train_feed = {x: batch_xs, y_: batch_ys}_, step = sess.run([train_step, global_step], feed_dict=train_feed)print("successfully!")

InternalError: Blas GEMM launch failed : a.shape=(100, 784), b.shape=(784, 10), m=100, n=10...问题解决办法相关推荐

  1. failed to run cuBLAS routine cublasSgemm_v2: CUBLAS_STATUS_EXECUTION_FAILED Blas GEMM launch failed

    项目场景: 一个命名实体识别模型,BERT+BiGRU+CRF. 问题描述: 在以前的笔记本上面,显卡2060,python3.7,tensorflow1.13,cuda10.0,cudnn7.4一直 ...

  2. TensorFlow: couldn’t open CUDA library cupti64_80.dll、InternalError: Blas SGEMM launch failed

    1. couldn't open CUDA library cupti64_80.dll Win10 TensorFlow(gpu)安装详解 在资源管理器中查询 cupti64_80.dll 的位置. ...

  3. Blas SGEMM launch failed

  4. Eclipse launch failed.Binary not found解决方案

    配置完成后建立工程测试,发现建立Hello World c++ Project类型的项目后可以运行测试,直接建立空项目写个测试类无法运行,提示"launch failed.Binary no ...

  5. 成功解决Ubuntu下的make: gcc: Command not found Makefile:85: recipe for target 'obj/gemm.o' failed make: **

    成功解决Ubuntu下的make: gcc: Command not found Makefile:85: recipe for target 'obj/gemm.o' failed make: ** ...

  6. TortoiseSVN Launch Failed Error:系统找不到指定路径

    右键操作TortoiseSVN 各种报 Launch Failed Error:系统找不到指定路径 刚刚安装完成后出现的问题 解决方案:重启电脑

  7. 提示 launch failed

    2019独角兽企业重金招聘Python工程师标准>>> 错误提示:Could not launch"appName" process launch failed: ...

  8. Eclipse C++的配置问题launch failed binary not found

    首先下载eclipse c++ 我的是64bit版本 安装好MinGW,并配置好环境变量,参考我的博客 http://www.cnblogs.com/fickleness/p/3273044.html ...

  9. process launch failed: Security

    运行系统:iOS9.1 运行工具:xCode7.1.1 问题描述:在真机iPhone6上运行xCode案例时,会提示"Could not launch "iOSCase" ...

最新文章

  1. 【建站系列教程】7、SEO优化之meta标签【最后一篇】
  2. 中英文最大AI模型世界纪录产生,大模型竞赛新阶段来了
  3. Java IO 体系(一): 装饰者模式
  4. Python笔记总结(1)
  5. mysql--字段--索引的增删改查
  6. mysql 嵌入式_MySql移植到嵌入式Linux平台
  7. 黑客大佬:我是如何让50个文件一起骗过AI安防系统的?
  8. CUBA平台–新的Java企业应用程序框架
  9. 引入react文件报错_react.js引入router文件后报错
  10. 伽利略板子串口驱动安装问题
  11. 想用Python做自动化测试?Python反射机制的应用
  12. astar插件下载 就行_送给你们一个ps插件,5秒抠图神器,这个肯定是你找了很久的...
  13. 实习成长之路:MySQL四:深入浅出索引
  14. 肯定存在无摩擦力的材料
  15. mysql两个等号是什么运算符_什么是MySQL中的这个运算符=?
  16. CSU_1505_酷酷的单词
  17. python应用内部审计_软件机器人实现内部审计自动化变革,助力企业转型数字化审计...
  18. NOIP2015跳石头【二分答案(最小值最大化) | 贪心】
  19. SQLite Expert Professional v5.4.34-Crack
  20. 前端3D开发,你需要了解的知识汇总

热门文章

  1. rsort php,php中rsort函数实例用法
  2. php5 mysql 源_thinkphp6:访问多个mysql数据源(thinkphp6.0.5 / php 7.4.9)
  3. python 区块链_Python 模拟简单区块链
  4. char转化为cstring_C语言100题集合001-将一个数字字符串转换为一个整数
  5. mysql in和or扫描全表_MySQL对OR条件查询不支持优化,会进行全表扫描
  6. java为table添加一行_Js实现Table动态添加一行的小例子
  7. jsf服务_JSF dataTable示例
  8. 参数化测试 junit_JUnit参数化测试
  9. xcode swift_CocoaPods Swift XCode教程
  10. viewtype_Android RecyclerView示例–多个ViewType