基于TensorFlow深度学习的环境需求如下
1、Python
(略)
2、Anaconda
(略)
3、CUDA NVIDIA GPU computing toolkit
https://developer.nvidia.com/cuda-toolkit-archive
4、cuDNN 神经网络加速库(要与CUDA版本匹配)
https://developer.nvidia.com/rdp/cudnn-download
注:cuDNN需进行环境变量等配置,请参考其他文档
5、numpy库
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
注:使用pip安装出现超时的情况,请更换下载源,如豆瓣等。
6、TensorFlow GPU版
pip install -U tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple
注:CUDA,cuDNN,TensorFlow GPU等,可通过Anaconda命令自动安装,请查询其他文档
7、常用Python库
pip install -U ipython numpy matplotlib pillow pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
8(可选)、TensorFlow运行显存占用模式设置,避免显存大量浪费:***(注意缩进)***
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:# 设置 GPU 为增长式占用
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
print('succeed')
except RuntimeError as e:
# 打印异常
print(e)