0
votes

After many attempts to verify that my nvidia quadro M4000M is capable of tensor computations, Cuda installed correctly, cuda toolkit 8.0 installed correctly, deviceQuery and nvidia-smi confirms that the device is functioning properly.

deviceQuery

nvidia-smi

When running tensorflow's example:

import tensorflow as tf

with tf.device("/gpu:0"):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a', dtype=tf.float32)
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b', dtype=tf.float32)
    c = tf.matmul(a, b)

sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=False,log_device_placement=True)) 
print(sess.run(c))

I don't get the device mapping information and the only way I can get the session to complete is to change the allow_soft_placement=True, which doesn't appear to use the GPU.

When allow_soft_placement = False for tf.device("/gpu:0") or /cpu:0 the error is:

InvalidArgumentError Traceback (most recent call last) ~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args) 1291 try: -> 1292 return fn(*args) 1293 except errors.OpError as e:

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata) 1274 # Ensure any changes to the graph are reflected in the runtime. -> 1275 self._extend_graph() 1276 return self._call_tf_sessionrun(

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _extend_graph(self) 1311 with self._graph._session_run_lock(): # pylint: disable=protected-access -> 1312 tf_session.ExtendSession(self._session) 1313

InvalidArgumentError: Cannot assign a device for operation 'MatMul': 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 MatMul}} = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](a, b)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError Traceback (most recent call last) in 7 sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=False,log_device_placement=True)) 8 ----> 9 print(sess.run(c)) 10 11

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 885 try: 886 result = self._run(None, fetches, feed_dict, options_ptr, --> 887 run_metadata_ptr) 888 if run_metadata: 889 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1108 if final_fetches or final_targets or (handle and feed_dict_tensor): 1109 results = self._do_run(handle, final_targets, final_fetches, -> 1110 feed_dict_tensor, options, run_metadata) 1111 else: 1112 results = []

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1284 if handle is None: 1285 return self._do_call(_run_fn, feeds, fetches, targets, options, -> 1286 run_metadata) 1287 else: 1288 return self._do_call(_prun_fn, handle, feeds, fetches)

~\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args) 1306
self._config.experimental.client_handles_error_formatting): 1307
message = error_interpolation.interpolate(message, self._graph) -> 1308 raise type(e)(node_def, op, message) 1309 1310 def _extend_graph(self):

InvalidArgumentError: Cannot assign a device for operation 'MatMul': 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 MatMul}} = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](a, b)]]

Caused by op 'MatMul', defined at: File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel_launcher.py", line 16, in app.launch_new_instance() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\kernelapp.py", line 499, in start self.io_loop.start() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\platform\asyncio.py", line 132, in start self.asyncio_loop.run_forever() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\asyncio\base_events.py", line 422, in run_forever self._run_once() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\asyncio\base_events.py", line 1434, in _run_once handle._run() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\asyncio\events.py", line 145, in _run self._callback(*self._args) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\ioloop.py", line 758, in _run_callback ret = callback() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\stack_context.py", line 300, in null_wrapper return fn(*args, **kwargs) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\gen.py", line 1233, in inner self.run() File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\gen.py", line 1147, in run yielded = self.gen.send(value) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\kernelbase.py", line 346, in process_one yield gen.maybe_future(dispatch(*args)) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\kernelbase.py", line 259, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\kernelbase.py", line 513, in execute_request user_expressions, allow_stdin, File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\ipkernel.py", line 294, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\ipykernel\zmqshell.py", line 536, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\interactiveshell.py", line 2817, in run_cell raw_cell, store_history, silent, shell_futures) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\interactiveshell.py", line 2843, in _run_cell return runner(coro) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\async_helpers.py", line 67, in _pseudo_sync_runner coro.send(None) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\interactiveshell.py", line 3018, in run_cell_async interactivity=interactivity, compiler=compiler, result=result) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\interactiveshell.py", line 3183, in run_ast_nodes if (yield from self.run_code(code, result)): File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\IPython\core\interactiveshell.py", line 3265, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 5, in c = tf.matmul(a, b) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\ops\math_ops.py", line 2053, in matmul a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 4856, in mat_mul name=name) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func return func(*args, **kwargs) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\framework\ops.py", line 3272, in create_op op_def=op_def) File "C:\Users\sellersp\AppData\Local\conda\conda\envs\tensor\lib\site-packages\tensorflow\python\framework\ops.py", line 1768, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'MatMul': 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 MatMul}} = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](a, b)]]

After searching many locations I can't seem to find where my error is. I've run it in a Jupyter Notebook and as a script at the interpreter.

Any help would be greatly appreciated. Sorry for the lengthy error.

1

1 Answers

0
votes

Have you installed tensorflow-gpu? Tensorflow has two binary packages (tensorflow-gpu and tensorflow). https://www.tensorflow.org/install/pip