https://stackoverflow.com/questions/43002915/loading-a-shared-library-cuda-in-python-via-ctypes-cannot-dynamically-loadin short:$ nvcc --ptxas-options=-v --compiler-options '-fPIC' --shared -o test_function.so testCuda.cuthe reference document linked from the above: http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#options-for-altering-compiler-linker-behavior