Python script for compiling CUDA

I’ve been trying to write a python script which compiles and runs CUDA code (specifically nbody sample).

nvcc_options_dll = ['nvcc', '-I inc','-x','cu','-G','-g','-DWIN64', '-lib', '-ccbin', 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx86/x64','--machine','64', '--compile','-cudart','static','-Xcompiler', '/EHsc /nologo /FS /Zi /MTd', 'nbody.cpp', '-o', 'nbody.exe']

With this code I am able to compile nbody.cpp, unfortunately when trying to run .exe file it appears that the application is 16bit and is incompatible with 64bit versions of Windows.

On the contrary, .exe file works flawlessly if code is compiled using Visual Studio.

Here are compilation parameters from Visual Studio

# Runtime API (NVCC Compilation Type is hybrid object or .c file)
set CUDAFE_FLAGS=--sdk_dir "E:\Windows Kits\10\"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc.exe" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64" -x cu  -I./ -I../../common/inc   -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static  -g   -DWIN32 -Xcompiler "/EHsc  /nologo   /FS /Zi  /MTd " -o x64/Debug/%(Filename)%(Extension).obj "%(FullPath)"

My GPU - 960M, compute capability - 5.0
I appreciate any help

UPDATE: I’ve fixed my problem by using MSBuild instead of nvcc compiler.