简体   繁体   中英

What do “Blas GEMM launch failed” errors from Tensorflow mean?

I'm learning tensorflow reading a korean book. I just copied and pasted code of this book but this code shows me error message. I want to find about this but even I can't see which message I should find about. Can anyone help me please...?

Here is the code. (using jupyter notebook)

import tensorflow as tf
import numpy as np

x_data = np.array(
    [[0, 0], [1, 0], [1, 1], [0, 0], [0, 0], [0, 1]])

y_data = np.array([
    [1, 0, 0],  # 기타
    [0, 1, 0],  # 포유류
    [0, 0, 1],  # 조류
    [1, 0, 0],
    [1, 0, 0],
    [0, 0, 1]
])

X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)

W1 = tf.Variable(tf.random_uniform([2, 10], -1., 1.))
W2 = tf.Variable(tf.random_uniform([10, 3], -1., 1.))

b1 = tf.Variable(tf.zeros([10]))
b2 = tf.Variable(tf.zeros([3]))

L1 = tf.add(tf.matmul(X, W1), b1)
L1 = tf.nn.relu(L1)

model = tf.add(tf.matmul(L1, W2), b2)

cost = tf.reduce_mean(
    tf.nn.softmax_cross_entropy_with_logits_v2(labels=Y, logits=model))

optimizer = tf.train.AdamOptimizer(learning_rate=0.01)
train_op = optimizer.minimize(cost)

Until here there was no error, but from below cell the code made error message.

init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)

for step in range(100):
    sess.run(train_op, feed_dict={X: x_data, Y: y_data})

    if (step + 1) % 10 == 0:
        print(step + 1, sess.run(cost, feed_dict={X: x_data, Y: y_data}))

InternalError                             Traceback (most recent call last)
c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1321     try:
-> 1322       return fn(*args)
   1323     except errors.OpError as e:

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1306       return self._call_tf_sessionrun(
-> 1307           options, feed_dict, fetch_list, target_list, run_metadata)
   1308 

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1408           self._session, options, feed_dict, fetch_list, target_list,
-> 1409           run_metadata)
   1410     else:

InternalError: Blas GEMM launch failed : a.shape=(6, 2), b.shape=(2, 10), m=6, n=10, k=2
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_Placeholder_0_0/_3, Variable/read)]]

During handling of the above exception, another exception occurred:

InternalError                             Traceback (most recent call last)
<ipython-input-7-2e54042a3fcf> in <module>
      4 
      5 for step in range(100):
----> 6     sess.run(train_op, feed_dict={X: x_data, Y: y_data})
      7 
      8     if (step + 1) % 10 == 0:

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    898     try:
    899       result = self._run(None, fetches, feed_dict, options_ptr,
--> 900                          run_metadata_ptr)
    901       if run_metadata:
    902         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1133     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1134       results = self._do_run(handle, final_targets, final_fetches,
-> 1135                              feed_dict_tensor, options, run_metadata)
   1136     else:
   1137       results = []

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1314     if handle is None:
   1315       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1316                            run_metadata)
   1317     else:
   1318       return self._do_call(_prun_fn, handle, feeds, fetches)

c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1333         except KeyError:
   1334           pass
-> 1335       raise type(e)(node_def, op, message)
   1336 
   1337   def _extend_graph(self):

InternalError: Blas GEMM launch failed : a.shape=(6, 2), b.shape=(2, 10), m=6, n=10, k=2
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_Placeholder_0_0/_3, Variable/read)]]

Caused by op 'MatMul', defined at:
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\kernelapp.py", line 505, in start
    self.io_loop.start()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\platform\asyncio.py", line 127, in start
    self.asyncio_loop.run_forever()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\asyncio\base_events.py", line 421, in run_forever
    self._run_once()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\asyncio\base_events.py", line 1425, in _run_once
    handle._run()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\asyncio\events.py", line 127, in _run
    self._callback(*self._args)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\ioloop.py", line 759, in _run_callback
    ret = callback()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
    return fn(*args, **kwargs)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\gen.py", line 1199, in inner
    self.run()
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\gen.py", line 1113, in run
    yielded = self.gen.send(value)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\kernelbase.py", line 357, in process_one
    yield gen.maybe_future(dispatch(*args))
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\gen.py", line 315, in wrapper
    yielded = next(result)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\kernelbase.py", line 267, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\gen.py", line 315, in wrapper
    yielded = next(result)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\kernelbase.py", line 534, in execute_request
    user_expressions, allow_stdin,
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tornado\gen.py", line 315, in wrapper
    yielded = next(result)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\ipkernel.py", line 294, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\ipykernel\zmqshell.py", line 536, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\interactiveshell.py", line 2819, in run_cell
    raw_cell, store_history, silent, shell_futures)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\interactiveshell.py", line 2845, in _run_cell
    return runner(coro)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\async_helpers.py", line 67, in _pseudo_sync_runner
    coro.send(None)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\interactiveshell.py", line 3020, in run_cell_async
    interactivity=interactivity, compiler=compiler, result=result)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\interactiveshell.py", line 3185, in run_ast_nodes
    if (yield from self.run_code(code, result)):
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-4ad5b6dffb7c>", line 1, in <module>
    L1 = tf.add(tf.matmul(X, W1), b1)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\ops\math_ops.py", line 2122, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 4567, in mat_mul
    name=name)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\framework\ops.py", line 3392, in create_op
    op_def=op_def)
  File "c:\programdata\anaconda3\envs\ilovemeat\lib\site-packages\tensorflow\python\framework\ops.py", line 1718, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(6, 2), b.shape=(2, 10), m=6, n=10, k=2
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_Placeholder_0_0/_3, Variable/read)]]

Can anyone tell me what the problem is...? I wonder if the error message is hard to read so I put the picture of it here.

Message

Message

Message

Last cell is like below. Thanks for your help...!

prediction = tf.argmax(model, 1)
target = tf.argmax(Y, 1)
print('prediction:', sess.run(prediction, feed_dict={X: x_data}))
print('real value:', sess.run(target, feed_dict={Y: y_data}))

is_correct = tf.equal(prediction, target)
accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32))
print('accuracy: %.2f' % sess.run(accuracy * 100, feed_dict={X: x_data, Y: y_data}))

A few days have passed, there was no answer so I write it down myself. I closed all the notebooks and console prompt window, restarted jupyter notebook and it worked. I think the problem was about connections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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