tensorflow GPU windows下编译

1.首先配置环境cuda,cudnn开发运行环境,参考https://blog.csdn.net/m0_37605642/article/details/98854753

2.参考我的前一篇配置CPU版本编译环境。https://blog.csdn.net/andrew57/article/details/103396426

3.如果已经生成CPU版本,可以bazel clean一下。然后执行python configure.py,配置如下,和cpu版区别是cuda support。

Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
No XLA JIT support will be enabled for TensorFlow.

Do you wish to build TensorFlow with ROCm support? [y/N]: n
No ROCm support will be enabled for TensorFlow.

Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.

Found CUDA 10.0 in:
    D:/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64
    D:/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include
Found cuDNN 7 in:
    D:/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64
    D:/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include


Please specify a list of comma-separated CUDA compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 3.5,7.0]:


Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]:


Would you like to override eigen strong inline for some C++ compilation to reduce the compilation time? [Y/n]: Y
Eigen strong inline overridden.

3.分别生成dll lib,头文件生成参考前一篇CPU版本tensorflow生成。

bazel build --config=cuda //tensorflow:tensorflow_cc
bazel build --config=cuda //tensorflow:tensorflow_cc.lib

4.如果发生“Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED”,如下处理:

SessionOptions options;
options.config.mutable_gpu_options()->set_allow_growth(true);
options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(1.0);

5.环境差异大可能导致编译出的问题不一样,本次环境依然同前一篇。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值