一、TensorFlow-gpu环境的安装
使用这个代码安装的前提是你的深度学习已经环境存在
(例如:conda、pytorch、cuda、cudnn等环境)
TensorFlow版本对应GPU版本,自己选择版本,也可以忽略版本直接安装TensorFlow-gpu
conda create -n tf3 python==3.8
conda activate tf3
我的cuda环境是11.8、python是3.8、tensorflow-gpu==2.7.0
安装指令:
pip install tensorflow-gpu==2.7.0 -i https://pypi.mirrors.ustc.edu.cn/simple
测试tensorflow是否安装成功
python
import tensorflow as tf
print(tf.__version__)
#输出'2.0.0-alpha0'
print(tf.test.is_gpu_available())
#会输出True,则证明安装成功
python
#新版本的tf把tf.test.is_gpu_available()换成如下命令
import tensorflow as tf
tf.config.list_physical_devices('GPU')