Post

Replies

Boosts

Views

Activity

Reply to Cannot assign a device for operation ReadVariableOp
Hi I'm using Apple M1 Pro and OS is Monterey 12.3.1, and with tensorflow-macos 2.8.0 tensorflow-metal 0.4.0 Getting the same problem. While I added an augmentation layer to my model. Costs me like 3 hours to figure it out. My solution is, I manually assign gpu using with tf.device("/gpu:0"): like this: with tf.device("/gpu:0"): model.compile(loss="categorical_crossentropy", optimizer='adma', metrics=['accuracy']) history = model.fit(train_ds,epochs=epochs,validation_data=val_ds, use_multiprocessing=True) Don't need to change/add other code. Just a simple line of code. It worked like a charm for me, you guys can try it!!! I hope it is helpful to anyone who come across this strange problem.
Apr ’22