发新帖

[DEPRECATED] Build TensorFlow Source Code with Cuda 9.1 and cuDNN 7 on Windows

[复制链接]
471 2

快来加入 TensorFlowers 大家庭!

您需要 登录 才可以下载或查看,没有帐号?加入社区

x
本帖最后由 dong 于 2018-5-16 09:12 编辑

TL;DR
The other day, my teammate Jiang and I were setting up development environment on our Windows 10 machines. We just left Caffe and turned to TensorFlow (with GPU support version), so things seems to be not so easy.

We installed the following software/packages:
  • Python 3.6
  • CUDA 9.1 from NVIDIA
  • cuDNN 7 from NVIDIA


When everything’s ready, we tried to verify TensorFlow local installation with Python scripts offered by official site. But it says CUDA DLL cannot be found!!! WTF! I have checked PATH variable millions of times! After several modification of TensorFlow site-package scripts, I realize it could be a miss-match of CUDA version.

Go back to legacy CUDA 9.0 version? No no no, it is not what I like to do. So I simply do one thing: build it on my own.
Build from Git Repository
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake is the site you have to read carefully before installation. But I definitely know that you don’t want to read the document at all. So take my lead, and follow me into the dark.
Prerequisites
  • Of course you should have CUDA 9.1 and cuDNN 7 installed on your local machine and their directories should be added to PATH variable. Here is part of my PATH:        
  • Install Visual Studio 2015 Community edition. You can find standalone installation image on msdn.itellyou.cn or use online installation executable from Microsoft Visual Studio official site (which is kind of hard to find legacy releases).
  • Install CMake.
  • Install Swigwin. (This is a windows zip with executable file)
  • Git and Python 3.6


Step by Step
  • Clone TensorFlow repository. Before you get started, change to a temporary directory (no space in path). Run git clone https://github.com/tensorflow/tensorflow.git with git-bash, cmd or powershell.
  • Go to CMake folder. cd tensorflow\tensorflow\contrib\cmake.
  • Before further actions, you need to modify one line in CMakeLists.txt in cmake: Line 44: set(tensorflow_CUDA_VERSION "9.0" CACHE STRING "CUDA version to build against"): change “9.0” to “9.1”. Save the file. Then create a folder called “build” and move within it.
  • Execute: cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release
    -DSWIG_EXECUTABLE="C:/Libraries/swigwin/swig.exe" -DPYTHON_EXECUTABLE="C:\Program Files\Python36\python.exe
    " -DPYTHON_LIBRARIES="C:/Program Files/Python36/libs/python36.lib" -Dtensorflow_ENABLE_GPU=ON -DCUDNN_HOME="
    C:/Libraries/cuda" (All in one line). You should replace all the executable with your own.
  • Done generation. Find tensorflow.sln file in build folder and open with Visual Studio 2015.
  • Change build type from Debug to Release. Find ALL_BUILD in solution explorer and right-click, choose build.
  • Okay, now go back to bed and have a nice sleep. After that, it should be done.


宝宝实在等不了了,吃个蛋糕先!

本楼点评(0) 收起

精彩评论2

dong  TF豆豆  发表于 2018-5-16 09:11:42 | 显示全部楼层
清早起来补一句,建议还是用 CUDA 9.0 吧,因为有一部分编译出错的
本楼点评(0) 收起
滴血森卡  TF豆豆  发表于 2018-5-16 20:08:01 来自手机  | 显示全部楼层
dong 发表于 2018-5-16 09:11
清早起来补一句,建议还是用 CUDA 9.0 吧,因为有一部分编译出错的

赞呢。
本楼点评(0) 收起
您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

主题

帖子

69

积分
快速回复 返回顶部 返回列表