tensorflow / skflow

Simplified interface for TensorFlow (mimicking Scikit Learn) for Deep Learning
Apache License 2.0
3.18k stars 439 forks source link

when run multiple_gpu.py, I got this error #129

Closed kwangjun14 closed 8 years ago

kwangjun14 commented 8 years ago

InvalidArgumentError Traceback (most recent call last)

in () 19 20 classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3) ---> 21 classifier.fit(X_train, y_train) 22 score = metrics.accuracy_score(y_test, classifier.predict(X_test)) 23 print('Accuracy: {0:f}'.format(score)) /usr/local/lib/python2.7/dist-packages/skflow/estimators/base.pyc in fit(self, X, y, logdir) 200 self._setup_training() 201 # Initialize model parameters. --> 202 self._trainer.initialize(self._session) 203 self._initialized = True 204 /usr/local/lib/python2.7/dist-packages/skflow/trainer.pyc in initialize(self, sess) 109 Values of initializers. 110 """ --> 111 return sess.run(self._initializers) 112 113 def train(self, sess, feed_dict_fn, steps, /usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict) 313 `Tensor` that doesn't exist. 314 """ --> 315 return self._run(None, fetches, feed_dict) 316 317 def partial_run(self, handle, fetches, feed_dict=None): /usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict) 509 # Run request and get response. 510 results = self._do_run(handle, target_list, unique_fetches, --> 511 feed_dict_string) 512 513 # User may have fetched the same tensor multiple times, but we /usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_run(self, handle, target_list, fetch_list, feed_dict) 562 if handle is None: 563 return self._do_call(_run_fn, self._session, feed_dict, fetch_list, --> 564 target_list) 565 else: 566 return self._do_call(_prun_fn, self._session, handle, feed_dict, /usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_call(self, fn, *args) 584 # pylint: disable=protected-access 585 raise errors._make_specific_exception(node_def, op, error_message, --> 586 e.code) 587 # pylint: enable=protected-access 588 six.reraise(e_type, e_value, e_traceback) InvalidArgumentError: Cannot assign a device to node 'logistic_regression/bias': Could not satisfy explicit device specification '/device:GPU:2' [[Node: logistic_regression/bias = Variable[container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:2"]()]] Caused by op u'logistic_regression/bias', defined at: File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py", line 3, in app.launch_new_instance() File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 589, in launch_instance app.start() File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelapp.py", line 405, in start ioloop.IOLoop.instance().start() File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py", line 162, in start super(ZMQIOLoop, self).start() File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 840, in start handler_func(fd_obj, events) File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper return fn(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events self._handle_recv() File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv self._run_callback(callback, msg) File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback callback(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper return fn(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 260, in dispatcher return self.dispatch_shell(stream, msg) File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 212, in dispatch_shell handler(stream, idents, msg) File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 370, in execute_request user_expressions, allow_stdin) File "/usr/local/lib/python2.7/dist-packages/ipykernel/ipkernel.py", line 175, in do_execute shell.run_cell(code, store_history=store_history, silent=silent) File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2723, in run_cell interactivity=interactivity, compiler=compiler, result=result) File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2825, in run_ast_nodes if self.run_code(code, result): File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2885, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 21, in classifier.fit(X_train, y_train) File "/usr/local/lib/python2.7/dist-packages/skflow/estimators/base.py", line 200, in fit self._setup_training() File "/usr/local/lib/python2.7/dist-packages/skflow/estimators/base.py", line 139, in _setup_training self._inp, self._out) File "", line 18, in my_model return skflow.models.logistic_regression(layers, y) File "/usr/local/lib/python2.7/dist-packages/skflow/models.py", line 69, in logistic_regression bias = tf.get_variable('bias', [y.get_shape()[-1]]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 256, in get_variable trainable, collections) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 188, in get_variable self.reuse, trainable, collections) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 132, in get_variable collections=collections) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 195, in __init__ name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 237, in _init_from_args set_shape=validate_shape, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/state_ops.py", line 121, in variable_op container=container, shared_name=shared_name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 335, in _variable name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2040, in create_op original_op=self._default_original_op, op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1087, in __init__ self._traceback = _extract_stack()
terrytangyuan commented 8 years ago

Does this example work for you? Could you also check whether you have those devices on your computer?

terrytangyuan commented 8 years ago

Closing now due to inactive status but feel free to re-submit the issue on TensorFlow repo.