Skip to content
Advertisement

tf-nightly-gpu and Keras

So, I was able to get lucky and get my hands on an RTX 3070. Unfortunately, this isn’t working out as well as I would have liked for me when it comes to tensorflow. I’ve spent some time on google and from what I can tell, tf-nightly-gpu is the solution to my issues here.

I’ve installed Cuda 11/10, cuDNN, and tf-nightly-gpu, but I’m failing to make this work. I am a rookie here, so my hope is that I’m just doing something silly. I do not get this error with tensorflow installed, but my code also doesn’t use the GPU on the current build (terminology?). My understanding is that tf-nightly-gpu is my tensorflow install. Here are my includes:

from keras.models import Sequential
from keras.layers import Dense

Here is the error:

C:UsersGrimacePycharmProjectsEvovenvScriptspython.exe C:/Users/Grimace/PycharmProjects/Evo/HouseTest.py
Traceback (most recent call last):
  File "C:UsersGrimacePycharmProjectsEvovenvlibsite-packageskeras__init__.py", line 3, in <module>
    from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
ModuleNotFoundError: No module named 'tensorflow.keras.layers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Grimace/PycharmProjects/Evo/HouseTest.py", line 2, in <module>
    from keras.models import Sequential
  File "C:UsersGrimacePycharmProjectsEvovenvlibsite-packageskeras__init__.py", line 6, in <module>
    'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

Advertisement

Answer

You’re importing keras. For tf-nightly, and all recent versions of tensorflow please import tf.keras. Tensorflow nightly and tf.keras is working well on my 3090 with CUDA 11.1.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement