tensorflow使用model.fit()函数出错

问题遇到的现象和发生背景

使用tensorflow训练minist训练集,model.fit()函数出错;一开始使用cuda10.2时没问题,而后更新成11.2出现错误

img

望采纳

  • 这个错误是由于正在运行的程序所需的CUDA版本与安装的CUDA版本不匹配造成的。可以尝试在运行程序之前更新tensorflow-gpu软件包,或者将代码更改为使用您安装的CUDA版本。例如,如果你安装了CUDA 11.2,可以在运行代码之前添加以下行:
import tensorflow as tf

physical_devices = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(physical_devices[0], True)
tf.config.experimental.set_visible_devices(physical_devices[0], 'GPU')