title: Application not linking to CUDA
body: <p>I am trying to compile and run an application that depends on CUDA SDK. The CUDA shared objects are installed in the standard location on Ubuntu:</p>
  
  <pre><code>$ ls -l /usr/lib/x86_64-linux-gnu/libcuda*
  lrwxrwxrwx 1 root root       12 Feb 26 18:26 /usr/lib/x86_64-linux-gnu/libcuda.so -&gt; libcuda.so.1
  lrwxrwxrwx 1 root root       17 Feb 26 18:26 /usr/lib/x86_64-linux-gnu/libcuda.so.1 -&gt; libcuda.so.331.49
  -rw-r--r-- 1 root root 13871048 Feb 13 04:29 /usr/lib/x86_64-linux-gnu/libcuda.so.331.49
  -rw-r--r-- 1 root root   307722 Jul 19  2013 /usr/lib/x86_64-linux-gnu/libcudadevrt.a
  lrwxrwxrwx 1 root root       16 Jan 23 01:36 /usr/lib/x86_64-linux-gnu/libcudart.so -&gt; libcudart.so.5.5
  lrwxrwxrwx 1 root root       19 Jan 23 01:36 /usr/lib/x86_64-linux-gnu/libcudart.so.5.5 -&gt; libcudart.so.5.5.22
  -rw-r--r-- 1 root root   313400 Jul 19  2013 /usr/lib/x86_64-linux-gnu/libcudart.so.5.5.22
  -rw-r--r-- 1 root root   642322 Jul 19  2013 /usr/lib/x86_64-linux-gnu/libcudart_static.a
  </code></pre>
  
  <p>The application is properly linked to CUDA during compilation</p>
  
  <pre><code>LDFLAGS="-lcuda" CFLAGS="-O2 -march=native" ./configure --with-cuda=/usr/lib/x86_64-linux-gnu
  </code></pre>
  
  <p>No errors during make (gcc). When I run the binary, I get this error</p>
  
  <pre><code>$ ./cudaminer 
             *** CudaMiner for nVidia GPUs by Christian Buchner ***
                       This is version 2014-02-28 (beta)
          based on pooler-cpuminer 2.3.2 (c) 2010 Jeff Garzik, 2012 pooler
              Cuda additions Copyright 2013,2014 Christian Buchner
            LTC donation address: LKS1WDKGED647msBQfLBHV3Ls8sveGncnm
            BTC donation address: 16hJF5mceSojnTD3ZTUDqdRhDyPJzoRakM
            YAC donation address: Y87sptDEcpLkLeAuex6qZioDbvy1qXZEj4
  [2014-04-02 20:48:56] Unable to query CUDA driver version! Is an nVidia driver installed?
  </code></pre>
  
  <p><code>ldd</code> on the binary seems to be correct as well</p>
  
  <pre><code>$ ldd cudaminer|grep cuda
          libcudart.so.5.5 =&gt; /usr/lib/x86_64-linux-gnu/libcudart.so.5.5 (0x00007fe268048000)
  </code></pre>
  
  <h2>Source Code</h2>
  
  <p>The error can actually be traced back to the source code at <a href="https://github.com/cbuchner1/CudaMiner/blob/d8f335518051da530cbc87820bedadf653188ec7/salsa_kernel.cu" rel="nofollow">Github</a>, calling the function <code>cudaDriverGetVersion</code>. This function exist in the shared library</p>
  
  <pre><code>$ nm -D /usr/lib/x86_64-linux-gnu/libcuda.so|grep Version
  0000000000144fc0 T cuCtxGetApiVersion
  00000000002d2980 T cudbgGetAPIVersion
  00000000001476f0 T cuDriverGetVersion
  
  $ nm -D /usr/lib/x86_64-linux-gnu/libcudart.so|grep Version
  0000000000027810 T cudaDriverGetVersion
  0000000000027670 T cudaRuntimeGetVersion
  </code></pre>
  
  <p>What is causing the error here?</p>
  
  <hr>
  
  <h2>Update 1</h2>
  
  <p>Output of <code>nvidia-smi -a</code> is</p>
  
  <pre><code>==============NVSMI LOG==============
  
  Timestamp                       : Thu Apr  3 06:26:36 2014
  Driver Version                  : 304.121
  
  Attached GPUs                   : 1
  GPU 0000:00:03.0
      Product Name                : GRID K520
      Display Mode                : N/A
      Persistence Mode            : Disabled
      Driver Model
          Current                 : N/A
          Pending                 : N/A
      Serial Number               : N/A
      GPU UUID                    : GPU-1e3aafd5-e821-41a0-62de-3b8fe1b74dd2
      VBIOS Version               : 80.04.D4.00.03
      Inforom Version
          Image Version           : N/A
          OEM Object              : N/A
          ECC Object              : N/A
          Power Management Object : N/A
      GPU Operation Mode
          Current                 : N/A
          Pending                 : N/A
      PCI
          Bus                     : 0x00
          Device                  : 0x03
          Domain                  : 0x0000
          Device Id               : 0x118A10DE
          Bus Id                  : 0000:00:03.0
          Sub System Id           : 0x101410DE
          GPU Link Info
              PCIe Generation
                  Max             : N/A
                  Current         : N/A
              Link Width
                  Max             : N/A
                  Current         : N/A
      Fan Speed                   : N/A
      Performance State           : N/A
      Clocks Throttle Reasons     : N/A
      Memory Usage
          Total                   : 4095 MB
         Used                    : 10 MB
          Free                    : 4085 MB
      Compute Mode                : Default
      Utilization
          Gpu                     : N/A
          Memory                  : N/A
      Ecc Mode
          Current                 : N/A
          Pending                 : N/A
      ECC Errors
          Volatile
              Single Bit            
                  Device Memory   : N/A
                  Register File   : N/A
                  L1 Cache        : N/A
                  L2 Cache        : N/A
                  Texture Memory  : N/A
                  Total           : N/A
              Double Bit            
                  Device Memory   : N/A
                  Register File   : N/A
                  L1 Cache        : N/A
                  L2 Cache        : N/A
                  Texture Memory  : N/A
                  Total           : N/A
          Aggregate
              Single Bit            
                  Device Memory   : N/A
                  Register File   : N/A
                  L1 Cache        : N/A
                  L2 Cache        : N/A
                  Texture Memory  : N/A
                  Total           : N/A
              Double Bit            
                  Device Memory   : N/A
                  Register File   : N/A
                  L1 Cache        : N/A
                  L2 Cache        : N/A
                  Texture Memory  : N/A
                  Total           : N/A
      Temperature
          Gpu                     : 48 C
      Power Readings
          Power Management        : N/A
          Power Draw              : N/A
          Power Limit             : N/A
          Default Power Limit     : N/A
          Min Power Limit         : N/A
          Max Power Limit         : N/A
      Clocks
          Graphics                : N/A
          SM                      : N/A
          Memory                  : N/A
      Applications Clocks
          Graphics                : N/A
          Memory                  : N/A
      Max Clocks
          Graphics                : N/A
          SM                      : N/A
          Memory                  : N/A
      Compute Processes           : N/A
  </code></pre>