TensorFlow GPU
一、TensorFlow-GPU環(huán)境配置
0.查看自己的顯卡是否支持GPU計(jì)算加速
顯卡查看:https://www.geforce.com/hardware/technology/cuda/supported-gpus
CUDA安裝:https://www.cnblogs.com/wanyu416/p/9536853.html
cuDNN下載:https://developer.nvidia.com/cudnn
1.安裝TensorFlow-GPU
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ TensorFlow-GPU
2.安裝時(shí)出現(xiàn)ERROR: Cannot uninstall 'wrapt'問題的解決方案
pip install -U --ignore-installed wrapt enum34 simplejson netaddr
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu
3.導(dǎo)入時(shí)出現(xiàn)ImportError: Could not find 'cudart64_100.dll'問題的解決方案
https://blog.csdn.net/qq_29027865/article/details/93236034
4.查看設(shè)備信息
https://blog.csdn.net/qq_34022601/article/details/90449789
import os
from tensorflow.python.client import device_lib
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "99"
if __name__ == "__main__":
print(device_lib.list_local_devices())
二、使用GPU加速計(jì)算
1.指定計(jì)算設(shè)備
with tf.device('/gpu:0'):
需要加速計(jì)算圖節(jié)點(diǎn)
2.初始化cuDNN
init = tf.global_variables_initializer()
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
session.run(init)