neural-style-tf icon indicating copy to clipboard operation
neural-style-tf copied to clipboard

can't assign GPU

Open kaismax opened this issue 6 years ago • 4 comments

i had this erreur $ bash stylize_image.sh ./image_input/lion.jpg ./styles/kandinsky.jpg

Did you install the required dependencies? [y/n]

y

Do you have a CUDA enabled GPU? [y/n]

y Rendering stylized image. This may take a while...

---- RENDERING SINGLE IMAGE ----

2018-06-11 12:54:36.027672: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2018-06-11 12:54:36.028359: E tensorflow/stream_executor/cuda/cuda_driver.cc:406] failed call to cuInit: CUDA_ERROR_UNKNOWN 2018-06-11 12:54:36.028384: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: kais-X550JX 2018-06-11 12:54:36.028402: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: kais-X550JX 2018-06-11 12:54:36.028443: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 384.130.0 2018-06-11 12:54:36.028504: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 384.130.0 2018-06-11 12:54:36.028513: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 384.130.0

BUILDING VGG-19 NETWORK loading model weights... constructing layers... LAYER GROUP 1 --conv1_1 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 3, 64) --relu1_1 | shape=(1, 512, 512, 64) | bias_shape=(64,) --conv1_2 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 64, 64) --relu1_2 | shape=(1, 512, 512, 64) | bias_shape=(64,) --pool1 | shape=(1, 256, 256, 64) LAYER GROUP 2 --conv2_1 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 64, 128) --relu2_1 | shape=(1, 256, 256, 128) | bias_shape=(128,) --conv2_2 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 128, 128) --relu2_2 | shape=(1, 256, 256, 128) | bias_shape=(128,) --pool2 | shape=(1, 128, 128, 128) LAYER GROUP 3 --conv3_1 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 128, 256) --relu3_1 | shape=(1, 128, 128, 256) | bias_shape=(256,) --conv3_2 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256) --relu3_2 | shape=(1, 128, 128, 256) | bias_shape=(256,) --conv3_3 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256) --relu3_3 | shape=(1, 128, 128, 256) | bias_shape=(256,) --conv3_4 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256) --relu3_4 | shape=(1, 128, 128, 256) | bias_shape=(256,) --pool3 | shape=(1, 64, 64, 256) LAYER GROUP 4 --conv4_1 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 256, 512) --relu4_1 | shape=(1, 64, 64, 512) | bias_shape=(512,) --conv4_2 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512) --relu4_2 | shape=(1, 64, 64, 512) | bias_shape=(512,) --conv4_3 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512) --relu4_3 | shape=(1, 64, 64, 512) | bias_shape=(512,) --conv4_4 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512) --relu4_4 | shape=(1, 64, 64, 512) | bias_shape=(512,) --pool4 | shape=(1, 32, 32, 512) LAYER GROUP 5 --conv5_1 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512) --relu5_1 | shape=(1, 32, 32, 512) | bias_shape=(512,) --conv5_2 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512) --relu5_2 | shape=(1, 32, 32, 512) | bias_shape=(512,) --conv5_3 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512) --relu5_3 | shape=(1, 32, 32, 512) | bias_shape=(512,) --conv5_4 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512) --relu5_4 | shape=(1, 32, 32, 512) | bias_shape=(512,) --pool5 | shape=(1, 16, 16, 512) Traceback (most recent call last): File "neural_style.py", line 856, in main() File "neural_style.py", line 853, in main else: render_single_image() File "neural_style.py", line 822, in render_single_image stylize(content_img, style_imgs, init_img) File "neural_style.py", line 556, in stylize L_style = sum_style_losses(sess, net, style_imgs) File "neural_style.py", line 410, in sum_style_losses sess.run(net['input'].assign(img)) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'Variable': 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: Variable = VariableV2container="", dtype=DT_FLOAT, shape=[1,512,512,3], shared_name="", _device="/device:GPU:0"]]

Caused by op u'Variable', defined at: File "neural_style.py", line 856, in main() File "neural_style.py", line 853, in main else: render_single_image() File "neural_style.py", line 822, in render_single_image stylize(content_img, style_imgs, init_img) File "neural_style.py", line 550, in stylize net = build_model(content_img) File "neural_style.py", line 243, in build_model net['input'] = tf.Variable(np.zeros((1, h, w, d), dtype=np.float32)) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 235, in init constraint=constraint) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 371, in _init_from_args name=name) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 137, in variable_op_v2 shared_name=shared_name) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 1255, in variable_v2 shared_name=shared_name, name=name) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/kais/pythonVE2/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1718, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'Variable': 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: Variable = VariableV2container="", dtype=DT_FLOAT, shape=[1,512,512,3], shared_name="", _device="/device:GPU:0"]]

kaismax avatar Jun 11 '18 11:06 kaismax

Try running pip install tensorflow-gpu, it might help

ivan-rivera avatar Sep 26 '18 20:09 ivan-rivera

@ivan-rivera : It didn't help.

abhinav3 avatar Nov 23 '18 05:11 abhinav3

@kaismax : Were you able to solve the issue?

abhinav3 avatar Nov 23 '18 05:11 abhinav3

conda install tensorflow-gpu==1.3.0 is what solved my problem. This tensor flow gpu version is compatible with Cuda tool kit 8

abhinav3 avatar Nov 23 '18 09:11 abhinav3