Win10 VS2017+cuda10.0+python3.6. Tensorflow源码安装

本文详细记录了在Win10系统中,使用Visual Studio 2017、CUDA 10.0和Python 3.6.6从源码编译安装Tensorflow的过程。涉及安装MSYS2、Bazel,配置环境变量,解决编译过程中遇到的问题,最终成功生成并安装Tensorflow库。
摘要由CSDN通过智能技术生成

Win10+VS2017+cuda10.0+python3.6.6 tensorflow源码安装

实验室的新项目需要用tensorflow,因此尝试了一下用源码编译最适合自己环境的库,断断续续历时4天,期间遇到众多大坑,好在github上大部分都能搜到解决方案。这里把自己遇到的问题集中总结一下。

Visual Studio 2017和Python

  1. 首先是编译器,VS2017,默认安装位置,由于安装VS的时候可以选择Python环境,所以同时在VS2017上安装了Python 3.6.6。这里需要注意在Visual Studio Installer 的单个组件中勾选 用于桌面 C++ [x86 和 x64]的 Windows 10 SDK (10.0.15063.0)(后面安装的CUDA10.0的例子需要该版本的SDK来编译)。

  2. 安装完成后,将Python.exe的路径添加到系统环境变量,如D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;同时将Scripts的路径也添加,如D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts。

  3. 打开cmd(我的cmd都是管理员模式),输入python检查是否安装成功。成功后可输入*exit()*退出python,然后使用以下命令安装相关phython 环境:

    pip3 install six numpy wheel
    pip3 install keras_applications1.0.5 --no-d

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.支持mkl,无MPI; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/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. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]:/home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: 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. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: hp@dla:~/work/ts_compile/tensorflow$ bazel build --config=opt --config=mkl --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
### 回答1: OpenCV是一个开源的计算机视觉和机器学习库,可以方便地处理图像和视频。而CUDA(Compute Unified Device Architecture)是由NVIDIA开发的一种并行计算架构,可以加速图形处理器(GPU)上的计算任务。 OpenCV 4.5.1是OpenCV的一个版本,它提供了丰富的功能和算法,用于图像和视频处理、特征提取、目标检测等任务。这个版本可以在Windows 10操作系统上使用,并且可以与Visual Studio 2017集成,提供开发环境和调试工具。 CUDA 10.0是NVIDIA的一个版本,它支持NVIDIA GPU上的并行计算任务。它允许开发人员使用C语言、C++或CUDA自己的扩展语言编写并行计算代码,以加速计算密集型任务。例如,在图像处理中,可以使用CUDA加速OpenCV算法,从而提高计算性能。 而cuDNN(CUDA Deep Neural Network library)是NVIDIA专门为深度学习任务开发的一个库。它提供了一组高性能的深度神经网络的基本操作和优化算法,可以与CUDA和OpenCV结合使用。 综上所述,OpenCV 4.5.1可以与CUDA 10.0和cuDNN 7.6.0集成使用。开发者可以在Visual Studio 2017中使用这些工具和库进行图像处理和机器学习任务的开发和优化。通过使用CUDA加速,可以提高计算性能,而cuDNN可以提供深度学习任务所需的算法和操作。 ### 回答2: OpenCV 4.5.1是一个计算机视觉库,用于在计算机视觉和机器学习项目中进行图像和视频处理。VS2017是一个集成开发环境(IDE),用于Windows操作系统上的软件开发。CUDA(Compute Unified Device Architecture)是一个用于GPU计算的并行计算平台和API模型。CUDNN是NVIDIA深度神经网络库,用于在GPU上加速深度学习任务。 在Windows 10上使用VS2017来编译OpenCV 4.5.1,并在CUDA 10.0和CUDNN 7.6.0的支持下进行构建可以提供更好的计算性能和加速。CUDA 10.0提供了与CUDA架构和驱动程序的兼容性,并支持许多NVIDIA GPU。CUDNN 7.6.0是基于CUDA的深度神经网络库,可以加速深度学习任务的训练和推理。 使用VS2017编译OpenCV可以让开发者方便地在Windows平台上进行开发和调试。VS2017提供了强大的集成开发环境,它可以帮助开发者编写、调试和测试程序。通过配置CUDA 10.0和CUDNN 7.6.0来支持OpenCV的GPU加速,可以进一步提高图像和视频处理的速度和效率。 总结来说,使用OpenCV 4.5.1、VS2017、Windows 10、CUDA 10.0和CUDNN 7.6.0可以实现在Windows平台上的高效计算机视觉和机器学习开发。这种配置可以提供更好的性能和加速,特别是在需要处理大量图像和视频、进行深度学习任务的情况下。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值