1、删除原有的tensorflow
通过conda list命令查看tensorflow安装的版本
conda命令行中输入
pip uninstall tensorflow==2.17.0
2、安装tensorflow
url:https://github.com/tensorflow/tensorflow
tensoflow在github上直接给出的安装方式
pip install tensorflow
pip install tensorflow-cpu #CPU版
3、检验是否安装成功
方式一(github官方)
import tensorflow as tf
tf.add(1, 2).numpy()
hello = tf.constant('Hello, TensorFlow!')
hello.numpy()
方式二
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
上述方式表明安装为CPU版,若安装为GPU版会显示“GPU”
(⚠️Tips:安装GPU版应该需要提前安装好CUDA Toolkit+cuDNN,后续有需要再安装)