前提
https://qiita.com/ya-ya-kaz716/items/39bbd91e65277004009b
上記のサイトを参考styleGANの実行を行っています。
途中まではうまくいくのですが、画像を生成するところでエラーが発生します。
発生している問題・エラーメッセージ
InvalidArgumentError Traceback (most recent call last) <ipython-input-14-f04512004dce> in <module> 1 # Generate image. 2 fmt = dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True) ----> 3 images = Gs.run(latents, None, truncation_psi=0.7, randomize_noise=True, output_transform=fmt) 4 plt.imshow(images[0]) 5 plt.tick_params(labelbottom="off",bottom="off") /content/drive/My Drive/stylegans/stylegan/dnnlib/tflib/network.py in run(self, input_transform, output_transform, return_as_list, print_progress, minibatch_size, num_gpus, assume_frozen, *in_arrays, **dynamic_kwargs) 441 mb_num = mb_end - mb_begin 442 mb_in = [src[mb_begin : mb_end] if src is not None else np.zeros([mb_num] + shape[1:]) for src, shape in zip(in_arrays, self.input_shapes)] --> 443 mb_out = tf.get_default_session().run(out_expr, dict(zip(in_expr, mb_in))) 444 445 for dst, src in zip(out_arrays, mb_out): /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 954 try: 955 result = self._run(None, fetches, feed_dict, options_ptr, --> 956 run_metadata_ptr) 957 if run_metadata: 958 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1178 if final_fetches or final_targets or (handle and feed_dict_tensor): 1179 results = self._do_run(handle, final_targets, final_fetches, -> 1180 feed_dict_tensor, options, run_metadata) 1181 else: 1182 results = [] /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1357 if handle is None: 1358 return self._do_call(_run_fn, feeds, fetches, targets, options, -> 1359 run_metadata) 1360 else: 1361 return self._do_call(_prun_fn, handle, feeds, fetches) /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/client/session.py in _do_call(self, fn, *args) 1382 '\nsession_config.graph_options.rewrite_options.' 1383 'disable_meta_optimizer = True') -> 1384 raise type(e)(node_def, op, message) 1385 1386 def _extend_graph(self): InvalidArgumentError: Cannot assign a device for operation Gs_1/_Run/Gs/latents_in: node Gs_1/_Run/Gs/latents_in (defined at /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/framework/ops.py:1748) was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:XLA_CPU:0, /job:localhost/replica:0/task:0/device:XLA_GPU:0 ]. Make sure the device specification refers to a valid device. [[Gs_1/_Run/Gs/latents_in]]
該当のソースコード
python
1# Generate image. 2fmt = dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True) 3images = Gs.run(latents, None, truncation_psi=0.7, randomize_noise=True, output_transform=fmt) 4plt.imshow(images[0]) 5plt.tick_params(labelbottom="off",bottom="off") 6plt.tick_params(labelleft="off",left="off")
回答1件
あなたの回答
tips
プレビュー