ANACONDA创建虚拟环境:
选择合适python版本,否则无法下载tensorflow。
启动终端。
安装Tensorflow2.5.0:需要指定版本,并指定cpu还是gpu版本。
非源码安装后,调用会产生警告。参考:
https://blog.csdn.net/weixin_43159148/article/details/89609870
完毕后,验证,tensorflow1和2版本相差较大,网上的验证代码多是1代,下面提供2带验证代码:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant(‘hello,tensorflow’)
sess= tf.compat.v1.Session()
print(sess.run(hello))