Distutils cannot compile CUDA by default, because it does not support the simultaneous use of multiple compilers. By default, it installs the compiler based only on your platform, and not on the type of source code that you have.
I have an example project on github that contains some monkey patches in distutils to crack support for this. An example project is a C ++ class that manages some GPU memory and a CUDA core wrapped in swig, and everything is compiled only with python setup.py install
. The focus is on array operations, so we also use numpy. The entire core for this sample project increments each element of the array by one.
Code here: https://github.com/rmcgibbo/npcuda-example . Here's the setup.py script. The key to all code is customize_compiler_for_nvcc()
.
import os from os.path import join as pjoin from setuptools import setup from distutils.extension import Extension from distutils.command.build_ext import build_ext import subprocess import numpy def find_in_path(name, path): "Find a file in a search path"
source share