前置环境需要安装cuda10.0和对应的cudnn
不在赘述,如需查看请参考这两篇博客(面向小白的,十分详细):
手把手教你win10安装Paddlepaddle-GPU(一)
手把手教你win10安装Paddlepaddle-GPU(二)
(注:猜测,如果没有MSVC2017的环境,conda可能会帮咱们安装)
同时,tf2.0也需要MSVC 2017的环境,tf2.0+的版本可能需要更高版本的MSVC环境
大家自己安装一下:
https://visualstudio.microsoft.com/zh-hans/downloads/
这是2019的版本,我们要往下拉,找到这个:
这里可能要登录一下你的微软账号了,点击下载
之后就是默认的安装了,推荐甭安装在启动盘
接下来最简单,直接pip就行:
pip install tensorflow-gpu==2.0.0-alpha0 -i https://mirror.baidu.com/pypi/simple
静静地等待其安装完毕
最后测试一下,是否安装成功,返回True即可
>>> import tensorflow as tf
>>> tf.test.is_gpu_available()
True
中间可能会有一些log,正常现象不用管:
2020-08-08 12:53:37.247411: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-08-08 12:53:37.265652: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2020-08-08 12:53:38.508922: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1467] Found device 0 with properties:
name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.493
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.30GiB
2020-08-08 12:53:38.516211: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1546] Adding visible gpu devices: 0
2020-08-08 12:53:39.183472: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1015] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-08-08 12:53:39.187729: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1021] 0
2020-08-08 12:53:39.189727: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1034] 0: N
2020-08-08 12:53:39.191917: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1149] Created TensorFlow device (/device:GPU:0 with 3012 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)