CUDA 6.5 allows you to build for sm_52 regardless of the GPU installed in your system. Obviously any sm_52 code generated will not be able to run on the K20.
How exactly does the build fail on the system with the K20? Without some details it is pretty much impossible to render assistance. As a piece of generic advice, check the paths set for executables, include files, and libraries. Check for inconsistent Visual Studio build settings. Due to the nature of the GUI, with build settings typically spread out all over the place, it is not uncommon for builds to build differently than the programmer intended. Turn on verbose settings to get a log of the exact invocation of nvcc and other build tools and their output, and compare this between the working and the non-working system.
What’s the output of nvcc --version on your two systems? On my Windows machine it looks like this:
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2014 NVIDIA Corporation
Built on Wed_Aug_27_10:28:57_CDT_2014
Cuda compilation tools, release 6.5, V6.5.16
If you’re going to upgrade, you might want to use CUDA 7 instead. I recognize you’ve got another thread going concerning r349 and higher drivers, but CUDA 7 ships with and only requires r346 drivers.