• Windows环境下使用tensorflow opencv的小事儿


    安装

    一、anaconda+tensorflow+opencv+spyder

    二、python+tensorflow+opencv+pycharm

    三、python3.5+tensorflow-gpu1.3+cuda8.0+cudnn6.0

    这两种方式我都尝试过了,第一种方式推荐一个博主的,写的很详细,能走通,但是要的时间很长,需要下很多东西,所以我用的第二种,因为时间比较赶

    ananconda+tensorflow安装:https://blog.csdn.net/weixin_37669436/article/details/71392905

    anaconda+opencv安装:https://blog.csdn.net/zstarwalker/article/details/72855781

    第二种首先下载python3.5.exe :https://www.python.org/downloads/release/python-350/

    记得要add python3.5.25 to path 

    其他的就默认就好,完成后Win+r输入cmd 键入python查看安装版本

    安装tensorflow隔了几天了有些问题可能记不清了,就写个大概的,如果大家安装遇到问题,给我留言,我会回的

    第一种是pip install tensorflow 

    要求是装了pip 还可能会遇到一个更新pip的问题,这个很好解决的,不知道大家能不能看懂命令行的提示,一般在一个问题出来了以后它会给你提供解决方案,按照他给的指令输入就好了,如果出现什么提交到github 这种提示,这个问题我也就解决不了了

    这方式存在一个问题是安装包都是在线上下,可能出现下不下来,网络中断这样的情况

    第二种 安装镜像文件,cd到镜像文件在的目录,运行镜像文件,可以下下来,也可以在线安装,我是下下来的,网址我找不到了一会儿给个百度网盘的地址分享出来吧

    运行命令是 pip install *.whl

    安装opencv

    要装很多的包  numpy scipy, matplotlib, opencv,...

    所以我装的镜像文件

    我都分享到网盘里,有问题找我

    网盘连接是https://pan.baidu.com/s/1815k5DT_p88FRC-gmJ-1cw  没有密码,里面是python3.5的安装包,tensorflow的镜像文件、opencv3的镜像文件

    我写的可能不是很详细,不过你不会装或者安装遇到什么问题可以找我,因为在这个里面爬了一个星期,希望可以减少大家的问题

     三、python3.5+tensorflow-gpu1.3+cuda8.0+cudnn6.0

    注意问题:版本对应

    cuda下载地址,可选择版本

    https://developer.nvidia.com/cuda-toolkit-archive

    cubnn下载地址,可以选择版本,需要注册,填写问卷调查,这是正常的,

    https://developer.nvidia.com/rdp/cudnn-archive

    cuda安装完成以后,将cubnn压缩包里的文件放到cuda安装地址对应的包里面,即bin对应bin include对应clude  lib对应lib,拷贝文件到相应的地址

    cuda默认安装的地址是 C:Program FilesNVIDIA GPU Computing ToolkitCUDA

    tensorflow1.3 更新  命令

    pip install --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/gpu/tensorflow_gpu-1.3.0rc0-cp35-cp35m-win_amd64.whl

    win10系统相关安装包分享:https://pan.baidu.com/s/11y7HIZwJ_JQxpikplmnuVg

     通过运行如下文件查看是否安装成功

    # -*- coding:utf-8-*-
    import ctypes
    import imp
    import sys
    
    
    def main():
        try:
            import tensorflow as tf
            print("TensorFlow successfully installed.")
            if tf.test.is_built_with_cuda():
                print("The installed version of TensorFlow includes GPU support.")
            else:
                print("The installed version of TensorFlow does not include GPU support.")
            sys.exit(0)
        except ImportError:
            print("ERROR: Failed to import the TensorFlow module.")
    
        candidate_explanation = False
    
        python_version = sys.version_info.major, sys.version_info.minor
        print("
    - Python version is %d.%d." % python_version)
        if not (python_version == (3, 5) or python_version == (3, 6)):
            candidate_explanation = True
            print("- The official distribution of TensorFlow for Windows requires "
                  "Python version 3.5 or 3.6.")
    
        try:
            _, pathname, _ = imp.find_module("tensorflow")
            print("
    - TensorFlow is installed at: %s" % pathname)
        except ImportError:
            candidate_explanation = False
            print("""  
    - No module named TensorFlow is installed in this Python environment. You may  
      install it using the command `pip install tensorflow`.""")
    
        try:
            msvcp140 = ctypes.WinDLL("msvcp140.dll")
        except OSError:
            candidate_explanation = True
            print("""  
    - Could not load 'msvcp140.dll'. TensorFlow requires that this DLL be  
      installed in a directory that is named in your %PATH% environment  
      variable. You may install this DLL by downloading Microsoft Visual  
      C++ 2015 Redistributable Update 3 from this URL:  
      https://www.microsoft.com/en-us/download/details.aspx?id=53587""")
    
        try:
            cudart64_80 = ctypes.WinDLL("cudart64_80.dll")
        except OSError:
            candidate_explanation = True
            print("""  
    - Could not load 'cudart64_80.dll'. The GPU version of TensorFlow  
      requires that this DLL be installed in a directory that is named in  
      your %PATH% environment variable. Download and install CUDA 8.0 from  
      this URL: https://developer.nvidia.com/cuda-toolkit""")
    
        try:
            nvcuda = ctypes.WinDLL("nvcuda.dll")
        except OSError:
            candidate_explanation = True
            print("""  
    - Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that  
      this DLL be installed in a directory that is named in your %PATH%  
      environment variable. Typically it is installed in 'C:WindowsSystem32'.  
      If it is not present, ensure that you have a CUDA-capable GPU with the  
      correct driver installed.""")
    
        cudnn5_found = False
        try:
            cudnn5 = ctypes.WinDLL("cudnn64_5.dll")
            cudnn5_found = True
        except OSError:
            candidate_explanation = True
            print("""  
    - Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow  
      requires that this DLL be installed in a directory that is named in  
      your %PATH% environment variable. Note that installing cuDNN is a  
      separate step from installing CUDA, and it is often found in a  
      different directory from the CUDA DLLs. You may install the  
      necessary DLL by downloading cuDNN 5.1 from this URL:  
      https://developer.nvidia.com/cudnn""")
    
        cudnn6_found = False
        try:
            cudnn = ctypes.WinDLL("cudnn64_6.dll")
            cudnn6_found = True
        except OSError:
            candidate_explanation = True
    
        if not cudnn5_found or not cudnn6_found:
            print()
            if not cudnn5_found and not cudnn6_found:
                print("- Could not find cuDNN.")
            elif not cudnn5_found:
                print("- Could not find cuDNN 5.1.")
            else:
                print("- Could not find cuDNN 6.")
                print("""  
      The GPU version of TensorFlow requires that the correct cuDNN DLL be installed  
      in a directory that is named in your %PATH% environment variable. Note that  
      installing cuDNN is a separate step from installing CUDA, and it is often  
      found in a different directory from the CUDA DLLs. The correct version of  
      cuDNN depends on your version of TensorFlow:  
    
      * TensorFlow 1.2.1 or earlier requires cuDNN 5.1. ('cudnn64_5.dll')  
      * TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')  
    
      You may install the necessary DLL by downloading cuDNN from this URL:  
      https://developer.nvidia.com/cudnn""")
    
        if not candidate_explanation:
            print("""  
    - All required DLLs appear to be present. Please open an issue on the  
      TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues""")
    
        sys.exit(-1)
    
    
    if __name__ == "__main__":
        main()




  • 相关阅读:
    单例模式(singleton)
    Unsupported major.minor version 51.0
    “万能数据库查询分析器”4.03发布,谨以此致我们终将逝去的青春
    和菜鸟一起学linux内核之初始化init篇
    PL/SQL备份oracle数据库
    java.lang.ClassCastException: org.apache.struts.taglib.bean.CookieTei
    DB Query Analyzer 4.03 is upgraded in ZOL
    Android应用程序资源的查找过程分析
    java.lang.IllegalArgumentException: Can't convert argument: null
    Dalvik虚拟机简要介绍和学习计划
  • 原文地址:https://www.cnblogs.com/html-css-js/p/8834623.html
Copyright © 2020-2023  润新知