title: Can't run CUDAfy.NET application on target device
body: <p>I've got an existing WinForms application on .NET 4.0 CP framework and I want it to do computations on CUDA devices. For this I decided to use <a href="https://cudafy.codeplex.com/" rel="nofollow">CUDAfy.NET</a> wrapper around C/C++ Toolkit, because it is (as far as I know) the only one up-to-date with CUDA SDK. The development is going without any major problems on my machine, but I've encountered troubles when deploying to another device.</p>
  
  <p>More specifically, when I build the project in VS and then run it on my machine, it runs fine. But the odd thing is that it runs nvcc.exe when initializing CUDAfy modules, which is a part of CUDA SDK and shouldn't be required there. And when I try to run the binary on any target machine it throws this exception:</p>
  
  <blockquote>
    <p>Cannot find compiler cl.exe in path.</p>
  </blockquote>
  
  <p>This is an error connected to missing VS tool for C++ compiler, and it shouln't arise on target devices. And now comes the weirdest thing; when I build the sample project that comes with CUDAfy.NET and try to run it on the target device, it throws the same exception.</p>
  
  <p>There is nothing wrong with the target machine, according to CUDAfy.NET test app <em>Cudafy Viewer</em> it is compatible and it has CUDA capability. Besides I've tested it on several different devices, always with the same result. I've traced the origin of the exception and as I indicated it is thrown when initializing CUDAfy.NET:</p>
  
  <pre><code>CudafyModule module = CudafyTranslator.Cudafy();
  GPGPU _gpu = CudafyHost.GetDevice(eGPUType.Cuda);
  _gpu.LoadModule(module);
  </code></pre>
  
  <p>According to <a href="http://www.hybriddsp.com/cudafy/CUDAfy_User_Manual_1_22.pdf" rel="nofollow">CUDAfy.NET User Manual</a> it should run perfectly fine on devices that meet these requirements:</p>
  
  <ul>
  <li>Windows 64-bit</li>
  <li>.NET 4.0</li>
  <li>NVIDIA GPU with compute capability 2.0 or higher</li>
  <li>Up to date NVIDIA drivers</li>
  <li>CURAND, CUSPARSE, CUFFT and CUBLAS dlls if using these math libraries</li>
  <li>Precompiled CUDAfy modules</li>
  </ul>
  
  <p>All of these are satisfied but it still doesn't run. That leaves me with a problem on my side and I'm pretty stuck there. </p>
  
  <p>One of the possibilities is that it is caused by wrong compilation of the code that is intended to be cudafied. According to the manual, and I quote, <em>"You generally would not cudafy your .NET code in a
  deployment situation as this requires the full CUDA SDK and Visual Studio. CUDAfy modules can be loose at .cdfy files or embedded in your application assembly (.exe or .dll) through use of the cudaycl command line tool."</em>. This should be done automatically, nonetheless I've tried using the cudaycl, ufortunatelly with no improvement. But since the exception occurs when initializing the CUDAfy, I think that source of the problem is elsewhere.</p>
  
  <p>What else might be causing it is that I build the binary for a specific architecture (e.g. CUDA 2.0) and then deploying it to another (e.g. CUDA 3.0). Something about it is mentioned in <a href="http://docs.nvidia.com/cuda/cuda-c-programming-guide/" rel="nofollow">CUDA Toolkit Documentation</a> in the section about nvcc compiler: <em>"Binary code is architecture-specific. A cubin object is generated using the compiler option -code that specifies the targeted architecture: For example, compiling with -code=sm_35 produces binary code for devices of compute capability 3.5."</em>.</p>
  
  <p>One way or another, I can't make it work right now. I would appreciate any help and suggestions you have. By the way I'm using latest CUDAfy.NET v1.29 and CUDA Toolkit 7.0 (the latest is not yet supported by CUDAfy.NET).</p>