-
Notifications
You must be signed in to change notification settings - Fork 631
Open
Description
TensorFlow device configuration fails after importing tensorflow_quantum
With the current version of tfq, importing the package before setting TensorFlow device configuration (e.g., enabling memory growth) results in a runtime error:
RuntimeError: Physical devices cannot be modified after being initialized
Expected Behavior
I would expect that importing tensorflow_quantum should not need to trigger device initialization yet, since I have not at this point created any tensors on any device.
Reproducer
import tensorflow as tf
import tensorflow_quantum as tfq
gpus = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True) # RuntimeError hereWorkaround
Set device configuration before importing tensorflow_quantum. This is fine for me, but since this is unexpected behaviour to me I am documenting it here.
Environment
- TensorFlow version: 2.15.0.post1
- TensorFlow Quantum version: 0.7.3
- Platform: Linux
Metadata
Metadata
Assignees
Labels
No labels