显卡计算能力profile文件修改

CUDA深度学习显卡算力文件修改

参考:aiuai

目的:在使用Pytorch进行深度学习训练的时候,在setup时需要对算力进行设置,根据机器使用的不同的GPU型号,需要改写nvcc编译使用的参数。

例如:

#!/usr/bin/env python3

import os

import torch

from setuptools import setup, find_packages

from torch.utils.cpp_extension import BuildExtension, CUDAExtension

cxx_args = ['-std=c++11']

nvcc_args = [

'-gencode', 'arch=compute_50,code=sm_50',

'-gencode', 'arch=compute_52,code=sm_52',

'-gencode', 'arch=compute_60,code=sm_60',

'-gencode', 'arch=compute_61,code=sm_61'

# '-gencode', 'arch=compute_70,code=sm_70',

# '-gencode', 'arch=compute_70,code=compute_70'

]

setup(

name='depthflowprojection_cuda',

ext_modules=[

CUDAExtension('depthflowprojection_cuda', [

'depthflowprojection_cuda.cc',

'depthflowprojection_cuda_kernel.cu'

], extra_compile_args={'cxx': cxx_args, 'nvcc': nvcc_args})

],

cmdclass={

'build_ext': BuildExtension

})