资源简介

文章地址https://blog.csdn.net/zbwindboy/article/details/79697068

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
“““
Created on Wed Mar 21 09:34:51 2018

@author: zhoubo
“““

#!/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‘]


# 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(‘nms.gpu_nms‘
                        sources=[
                                ‘nms\\gpu_nms.cu‘
                                ]
                        language=‘c++‘
                        libraries=cuda_libs
                        extra_compile_args=nvcc_compile_args
                        include_dirs = [numpy_include ‘C:\\Programming\\CUDA\\v7.5\\include‘])

ext_modules = [
    Extension(
        “utils.bbox“
        [“bbox.pyx“]
        extra_compile_args=nvcc_compile_args
        include_dirs = [numpy_include]
    )
    Extension(
        “utils.cython_nms“
        [“cython_nms.pyx“]
        extra_compile_args=nvcc_compile_args
        include_dirs = [numpy_include]
    )
    Extension(‘utils.gpu_nms‘
        [‘nms_kernel.cu‘ ‘gpu_nms.pyx‘]
        library_dirs=[‘C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\lib\\x64‘]
        libraries=cuda_libs
        language=‘c++‘
#        runtime_library_dirs=[‘C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\lib\\x64‘]
        extra_compile_args=nvcc_compile_args
        include_dirs = [numpy_include ‘C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.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
     

评论

共有 条评论