今天在运行tensorflow的一行代码时tf.data.Dataset.from_tensor_slices((x_train,y_train))
总是出现kernel dead,应该是tensorflow版本太高导致的。于是卸载tensorflow,重新安装低版本的,但中间出现各种报错。
于是,重新创建环境,安装python3.9所对应的tensorflow2.6.0版本。安装代码是python -m pip install tensorflow==2.6.0 -i https://pypi.douban.com/simple
,然后又报错。
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
- Downgrade the protobuf package to 3.20.x or lower.
- Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
按照上面所说的办法,安装低版本的protobuf也没有解决。
之后又使用pycharm创建环境,并使用pycharm安装tensorflow2.6.0版本,问题解决。