windows编译MaskRCNN-程序员宅基地

技术标签: python  


1.代码修改为3.0语言版本


2.setup_windows.py 文件内容为

#!/usr/bin/env python

import numpy as np
import os
# on Windows, we need the original PATH without Anaconda's compiler in it:
PATH = os.environ.get('PATH') + ';C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin'
from distutils.spawn import spawn, find_executable
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
import sys

# CUDA specific config
# nvcc is assumed to be in user's PATH
nvcc_compile_args = ['-O', '--ptxas-options=-v', '-arch=sm_35', '-c', '--compiler-options=-fPIC']
nvcc_compile_args = os.environ.get('NVCCFLAGS', '').split() + nvcc_compile_args
cuda_libs = ['cublas']
nvcc_bin = 'nvcc.exe'
lib_dir = 'lib/x64'

import distutils.msvc9compiler
distutils.msvc9compiler.VERSION = 14.0

# Obtain the numpy include directory.  This logic works across numpy versions.
try:
    numpy_include = np.get_include()
except AttributeError:
    numpy_include = np.get_numpy_include()


cudamat_ext = Extension('D:/Works/PyProj/Eric6/pyMaskrcnnMX/rcnn/mask/gpu_mv', ['D:/Works/PyProj/Eric6/pyMaskrcnnMX/rcnn/mask/gpu_mv.cu'],
                        language='c++',
                        libraries=cuda_libs,
                        extra_compile_args=nvcc_compile_args,
                        include_dirs=[numpy_include, 'C:\\Programming\\CUDA\\v8.0\\include'])

class CUDA_build_ext(build_ext):
    """
    Custom build_ext command that compiles CUDA files.
    Note that all extension source files will be processed with this compiler.
    """
    def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self)

    def spawn(self, cmd, search_path=1, verbose=0, dry_run=0):
        """
        Perform any CUDA specific customizations before actually launching
        compile/link etc. commands.
        """
        if (sys.platform == 'darwin' and len(cmd) >= 2 and cmd[0] == 'nvcc' and
                cmd[1] == '--shared' and cmd.count('-arch') > 0):
            # Versions of distutils on OSX earlier than 2.7.9 inject
            # '-arch x86_64' which we need to strip while using nvcc for
            # linking
            while True:
                try:
                    index = cmd.index('-arch')
                    del cmd[index:index+2]
                except ValueError:
                    break
        elif self.compiler.compiler_type == 'msvc':
            cmd[:1] = ['nvcc', '--compiler-bindir',
                       os.path.dirname(find_executable("cl.exe", PATH))
                       or cmd[0]]
            # - Secondly, we fix a bunch of command line arguments.
            for idx, c in enumerate(cmd):
                # create .dll instead of .pyd files
                #if '.pyd' in c: cmd[idx] = c = c.replace('.pyd', '.dll')  #20160601, by MrX
                # replace /c by -c
                if c == '/c': cmd[idx] = '-c'
                # replace /DLL by --shared
                elif c == '/DLL': cmd[idx] = '--shared'
                # remove --compiler-options=-fPIC
                elif '-fPIC' in c: del cmd[idx]
                # replace /Tc... by ...
                elif c.startswith('/Tc'): cmd[idx] = c[3:]
                # replace /Fo... by -o ...
                elif c.startswith('/Fo'): cmd[idx:idx+1] = ['-o', c[3:]]
                # replace /LIBPATH:... by -L...
                elif c.startswith('/LIBPATH:'): cmd[idx] = '-L' + c[9:]
                # replace /OUT:... by -o ...
                elif c.startswith('/OUT:'): cmd[idx:idx+1] = ['-o', c[5:]]
                # remove /EXPORT:initlibcudamat or /EXPORT:initlibcudalearn
                elif c.startswith('/EXPORT:'): del cmd[idx]
                # replace cublas.lib by -lcublas
                elif c == 'cublas.lib': cmd[idx] = '-lcublas'
            # - Finally, we pass on all arguments starting with a '/' to the
            #   compiler or linker, and have nvcc handle all other arguments
            if '--shared' in cmd:
                pass_on = '--linker-options='
                # we only need MSVCRT for a .dll, remove CMT if it sneaks in:
                cmd.append('/NODEFAULTLIB:libcmt.lib')
            else:
                pass_on = '--compiler-options='
            cmd = ([c for c in cmd if c[0] != '/'] +
                   [pass_on + ','.join(c for c in cmd if c[0] == '/')])
            # For the future: Apart from the wrongly set PATH by Anaconda, it
            # would suffice to run the following for compilation on Windows:
            # nvcc -c -O -o <file>.obj <file>.cu
            # And the following for linking:
            # nvcc --shared -o <file>.dll <file1>.obj <file2>.obj -lcublas
            # This could be done by a NVCCCompiler class for all platforms.
        spawn(cmd, search_path, verbose, dry_run)

setup(name="mask_voting_gpu",
      description="Performs linear algebra computation on the GPU via CUDA",
      ext_modules=[cudamat_ext],
      cmdclass={'build_ext': CUDA_build_ext},
)

出现错误:

LINK : fatal error LNK1181: 无法打开输入文件“ID=2.obj”

解决方法:




转载于:https://www.cnblogs.com/wishchin/p/9199891.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/alppkk4545/article/details/101575734

智能推荐

BAT批处理文件 拷贝与删除命令(copy,xcopy,del,rd)_bat copy-程序员宅基地

文章浏览阅读3.6w次,点赞12次,收藏41次。copy命令将一份或多份文件复制到另一个位置。COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B][+ source [/A | /B] [+ …]] [destination [/A | /B]]source指定要复制的文件。/A表示一个 ASCII 文本文件。/B表示一个二..._bat copy

iOS UIWebView URL拦截_ios webview 拦截请求使用本地资源-程序员宅基地

文章浏览阅读845次。本文译者:candeladiao,原文:URL filtering for UIWebView on the iPhone说明:译者在做app开发时,因为页面的javascript文件比较大导致加载速度很慢,所以想把javascript文件打包在app里,当UIWebView需要加载该脚本时就从app本地读取,但UIWebView并不支持加载本地资源。最后从下文中找到了解决方法,第一次翻译,难免有_ios webview 拦截请求使用本地资源

jsp中basepath的作用的思考_jsp文件中的basepath为啥-程序员宅基地

文章浏览阅读1.8k次。JSP里的basePath(本文为转载文章,文章转载自http://blog.csdn.net/lutinghuan/article/details/6450174)Eclipse 新建 jsp页面里自动生成以下代码:String path = request.getContextPath();String basePath = request.getScheme()+_jsp文件中的basepath为啥

httpclient常用基本抓取类_httpclient获得类标签-程序员宅基地

文章浏览阅读4.2k次。package com.reallyinfo.athena.crawlMethodManager;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import java.io.UnsupportedEn_httpclient获得类标签

单片机的ADC注意事项_dsp28034 adc运行卡死-程序员宅基地

文章浏览阅读1.4k次,点赞2次,收藏6次。大部分ADC转换的第一次是不准的,所以第一次先转换一下,丢弃,后面再转换,保存ADC 滤波方法建议采用中值平均滤波法,有两种,第一种占用内存烧,第二种滤波更好,占内存大,和时间慢 /*********************************************************函数名: unsigned int ADCRead()描 述: ADC转换程序,转换18次,..._dsp28034 adc运行卡死

cyj sql 收藏_sql语句中的ü-程序员宅基地

文章浏览阅读427次。select count(*) a,b from talble group BY b having count(*)>1 order BY a desc_sql语句中的ü

随便推点

程映虹:美国高中生如何识别媒体的政治偏见_解释媒体自由或保守背后的指控,如果你认为媒体偏向一个方向。你需要举一些例子,明-程序员宅基地

文章浏览阅读1.1k次。‌‌“学生每日新闻‌‌”经常选择各家媒体的重大报道,提供给各地的学生,让他们在读了这些报道后再去思考编辑就这些报道是否有‌‌“媒体的偏向‌‌”儿子上高中了,学校开学前照例设立‌‌“开门日‌‌”,邀请家长去参观。家长们根据自己孩子的选课被引导进不同的教室,听取不同的任课教师对课程的介绍。没想到,这个例行的家长和学校的互动带来了一个意外的收获,让我看到了这个被很多人认为是新闻自由、报道公正的社会是如何教_解释媒体自由或保守背后的指控,如果你认为媒体偏向一个方向。你需要举一些例子,明

地名经纬度互相转换_bmap 根据名称转经纬度-程序员宅基地

文章浏览阅读2.3k次。//经纬度转化为地名 var coser = new BMap.Geocoder(); coser.getLocation(new BMap.Point(116.401481,39.914776),function(result){ console.log(result); }) //地名转化为经纬度 var coser = new _bmap 根据名称转经纬度

Unity UGUI CanvasGroup组件的详解_unity canvas 中的grp-程序员宅基地

文章浏览阅读6.9k次,点赞4次,收藏8次。对于CanvasGroup组件,我们一定要引起高度重视,它很好用的呢。首先创建一个buttonBig,它很大♂,我将它的image里面的颜色alpha调至一半,颜色稍红。添加CanvasGroup组件然后创建两个小的button。他们都是默认的样子。之后调整大button,使大Button在小Button的上面。然后以大Button为父对象,创建一些UGUI的其他物件,像sli..._unity canvas 中的grp

所谓数据驱动,这个锅技术不能背。-程序员宅基地

文章浏览阅读304次。最近这几年,互联网有俩词挺流行,一个是数据驱动,一个是技术无罪。我们说很多产品决策的依据不是管理者拍脑袋,而是基于数据反馈,这当然是好事情。我们说互联网产生了很多新模式,..._点击提权 caoz

IP地址与子网掩码(网络地址与广播地址相关计算)_10.25.0.1子网掩码-程序员宅基地

文章浏览阅读5.5k次,点赞6次,收藏30次。文章目录一、IP地址1.1 IP地址的概念1.2 IP地址的分类私有地址1.3 IP地址的构成1.4 IP地址查询方式二、子网掩码2.1 子网掩码的概念2.2子网掩码的作用2.3子网掩码换算表三、网络地址四、广播地址五、利用以上内容解决问题一、IP地址1.1 IP地址的概念概念:IP地址是给每个连接在Internet上的主机分配的一个32bit地址。按照TCP/IP协议规定,IP地址用二进制来表示,每个IP地址长32bit,比特换算成字节,就是4个字节。包括主机地址和网络地址两部分。所以,IP地址由_10.25.0.1子网掩码

Web 趋势榜:上周不可错过的最热门的 10 大 Web 项目 - 210416-程序员宅基地

文章浏览阅读237次。大家好,我是你们的 猫哥,那个不喜欢吃鱼、又不喜欢喵 的超级猫 ~GitHub 上面有个 Trending 榜 (趋势榜),在 Trending 页面,你可以看到最近一些热门的开源项目或者..._github 一周热门