- 安装
pip install --upgrade pip
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow-gpu
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow-probability
- 验证
import tensorflow as tf
tf.__version__
#检验CPU版TensorFlow是否可用:
tf.reduce_sum(tf.random.normal([1000, 1000]))
#检验GPU版TensorFlow是否可用:
#tf.test.is_gpu_available()
tf.config.list_physical_devices('GPU') #检验GPU版TensorFlow是否可用:
- 另一种在ipython下验证的方法
import tensorflow as tf
with tf.device('/GPU:0'):
a = tf.constant(3)