Install Tensorflow GPU with CUDA 10.1 for python on Windows

How to install Tensorflow GPU with CUDA 10.0 for python on Windows

在cuda 10.0的windows上安装Tensorflow GPU, python

ref: https://www.pytorials.com/how-to-install-tensorflow-gpu-with-cuda-10-0-for-python-on-windows/

Before start, Notations neet to know:

Tasks (四位爷):

  1. 装 visual studio
  2. 装 Cuda
  3. 装 cuDNN
  4. 装 tensorflow

那么问题是,这四位爷的版本得对上。 所以就有人做了这个东西:https://github.com/fo40225/tensorflow-windows-wheel
里面详细列出来每个安装包对应的四位爷的版本。

以这一行:
1.14.0\py37\GPU\cuda101cudnn76avx2 VS2019 16.1 10.1.168_425.25/7.6.0.64 AVX2 Python 3.7/Compute 3.0,3.5,5.0,5.2,6.1,7.0,7.5

解释一下:

  • 第一列: 在github这个项目里,whl安装包的路径
  • 第二列: Compiler版本
  • 第三列: CUDA版本:10.1.168_425.25, cuDNN版本:7.6.0.64
  • 第四列: SIMD,即你的CPU支持的指令集是否支持AVX2. The tool coreinfo can tell you. get to know it by google.
  • 第五列: python版本,GPU的compute能力。ref: https://developer.nvidia.com/cuda-gpus

按照这5列的信息,就一步步装四位爷。

  • 装 visual studio
  • 装 Cuda
  • 装 cuDNN
  • 装 tensorflow

第一位爷,装 visual studio:上microsoft visual studio去下载安装vs 2019, 需了解tf是c++写的。

第二位爷,装 Cuda 10.1, 上nvidia去下载安装即可。(20190825: 注意cuda10.1 暂时不被pyTorch支持,如果有pyTorch需求的,建议cuda10.0)
装完cmd里检查版本号:nvcc --version
You will see something like this:
----
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Apr_24_19:11:20_Pacific_Daylight_Time_2019
Cuda compilation tools, release 10.1, V10.1.168

第三位爷,装cuDNN,
Goto https://developer.nvidia.com/cudnn (Membership required) After login Download the following: cuDNN v7.6.0.64 Library for Windows [your version] for me Windows 10 Goto downloaded folder and extract cudnn-10.0-windows10-x64-v7.3.1.20.zip Go inside extracted folder and copy all files and folder from cuda folder (Bin, include, lib) and paste them to “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1”.
对应的文件放在对应的所在文件夹中。
参考: https://zhuanlan.zhihu.com/p/49832216

第四位爷:装tensorflow-gpu
建立一个virtual environment with python=3.7 用conda。指定env的名字py3env-gpu, python版本=3.7, 顺带装上包:pip six numpu wheel mock 等。cmd中运行:

conda create -n py3env-gpu python=3.7 pip six numpy wheel mock

参考上述‘第一列: 在github这个项目里,whl安装包的路径’
下载tensorflow-gpu的whl安装文件,from this github: https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.14.0/py37/GPU/cuda101cudnn76avx2

这里面是001和002的压缩分卷,全下载解压。
cmd里到这个解压路径,用pip install 安装tensorflow-gpu,就完成了。

途中如果遇到connection的问题,用privoxy开个http代理,再在cmd里配一下代理服务器即可。参考:https://www.cnblogs.com/sonictl/p/11248627.html


个人经验,仅供参考,致敬:https://zhuanlan.zhihu.com/p/49832216

猜你喜欢

转载自www.cnblogs.com/sonictl/p/11237839.html