VS 2019 and CUDA 10.1 fatal error C1041 - Use /FS ???

I just installed MS VS 2019 and CUDA 10.1 and attempted to build my project that contains three .cu files (along with a bunch of .cpp files). If I sit there and repeatedly click “Rebuild”, it occasionally builds correctly, but most of the time it fails during the .cu compiles with this error:

fatal error C1041: cannot open program database ‘D:\VarScreen\x64\Debug\vc142.pdb’; if multiple CL.EXE write to the same .PDB file, please use /FS

I tried putting /FS several places and no matter what I did it either did nothing or caused another error.

What’s weird is that this is a random failure. If I try enough times, eventually (usually after just a few tries) it builds correctly. My guess is that the CUDA compiler is trying to write to the pdb file simultaneously from several threads and it’s hit or miss contention.

Any thoughts on how to fix this? Thank you!

Have you tried to disable multithreaded builds?

No. I didn’t know it was possible.

I’m having the same problem. Disabling multithreaded build didn’t change anything for me.

Thanks! :)

No solution for the problem? We have the same issue while building on Jenkins servers.
Playing around with FS flag hasn’t fixed it. Just building with just 1 thread works, but this isn’t recommended.

I’m on Windows 10. About a month or so after posting my message an update to CUDA fixed the problem.