You are re-wrapping your pred_mask into a new Variable, which detaches the computation graph.
Just try to use:
pred_mask = pred_mask > 0.5

Also, you could update to the latest release, where Variables and tensors were merged.
You can find the install instructions on the website 2 and the migration guide here 3.