0

I am trying to print the shape of the tensor (running the basic transformer code) using tensor2tensor. I see "?" in the shape. I tried doing the following:

    #with tf.Session() as sess:
    #  print(sess.run(x).shape)

But this gives me an error

cannot assign a device for operation transformer/parallel_0/transformer/Identity: {{node transformer/parallel_0/transformer/Identity}} 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.
         [[transformer/parallel_0/transformer/Identity]]

I also tried to use tf.print(tf.shape(x)) but that doesn't print anything

I am running the command :

t2t-decoder \
  --data_dir=$DATA_DIR \
  --problem=$PROBLEM \
  --model=$MODEL \
  --hparams_set=$HPARAMS \
  --output_dir=$TRAIN_DIR \
  --decode_hparams="beam_size=$BEAM_SIZE,alpha=$ALPHA" \
  --decode_from_file=$DECODE_FILE \
  --decode_to_file=translation.en

I don't know much about tensorflow, but I see that these are being used?

tf.compat.v1.train.MonitoredSession(
            session_creator=tf.compat.v1.train.ChiefSessionCreator(

How Can I print shape of tensor in such a scenario? Please help!!!

1 Answers1

0

cannot assign a device for operation transformer/parallel_0/transformer/Identity: {{node transformer/parallel_0/transformer/Identity}} 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. [[transformer/parallel_0/transformer/Identity]]

The error tells you that your code is trying to run on a GPU but can not find or access it. Do you have installed tensorflow or tensorflow-gpu? The later is the one you want if you want to use your GPU.

If you have installed tensorflow-gpu and the error is still there then you might want to check your version compatibility of tensroflow/cuda/python. Here is how you can do that.

Fabian
  • 756
  • 5
  • 12