CUDA: Difference between revisions

No edit summary
Line 39: Line 39:
Test PASSED</pre>
Test PASSED</pre>
Each device has a '''compute capability''', though this does not encompass all differentiated capabilities (see also <tt>deviceOverlap</tt> and <tt>canMapHostMemory</tt>...).
Each device has a '''compute capability''', though this does not encompass all differentiated capabilities (see also <tt>deviceOverlap</tt> and <tt>canMapHostMemory</tt>...).
==Installation on [[Debian]]==
[http://packages.debian.org/sid/libdevel/libcuda1-dev libcuda-dev] packages exist in the <tt>non-free</tt> archive area, and supply the core library <tt>libcuda.so</tt>. Together with the upstream toolkit and SDK from NVIDIA, this provides a full CUDA development environment for 64-bit Debian Unstable systems. I installed CUDA 2.3 on 2010-01-25 (hand-rolled 2.6.32.6 kernel, built with gcc-4.4). This machine did not have CUDA-compatible hardware (it uses [[Intel 965]]).
* Download the Ubuntu 9.04 files from NVIDIA's "[http://www.nvidia.com/object/cuda_get.html CUDA Zone]".
* Run the toolkit installer (<tt>sh cudatoolkit_2.3_linux_64_ubuntu9.04.run</tt>)
** For a user-mode install, supply <tt>$HOME/local</tt> or somesuch
<pre>* Please make sure your PATH includes /home/dank/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH
*  for 32-bit Linux distributions includes /home/dank/local/cuda/lib
*  for 64-bit Linux distributions includes /home/dank/local/cuda/lib64
* OR
*  for 32-bit Linux distributions add /home/dank/local/cuda/lib
*  for 64-bit Linux distributions add /home/dank/local/cuda/lib64
* to /etc/ld.so.conf and run ldconfig as root
* Please read the release notes in /home/dank/local/cuda/doc/
* To uninstall CUDA, delete /home/dank/local/cuda
* Installation Complete</pre>
* Run the SDK installer (<tt>sh cudasdk_2.3_linux.run</tt>)
** I just installed it to the same directory as the toolkit, which seems to work fine.
<pre>========================================
Configuring SDK Makefile (/home/dank/local/cuda/shared/common.mk)...
========================================
* Please make sure your PATH includes /home/dank/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH includes /home/dank/local/cuda/lib
* To uninstall the NVIDIA GPU Computing SDK, please delete /home/dank/local/cuda
* Installation Complete</pre>
==Building CUDA Apps==
===<tt>nvcc</tt> flags===
* <tt>-ptax-options=-v</tt> displays per-thread register usage
===SDK's common.mk===
This assumes use of the SDK's common.mk, as recommended by the documentation.
* Add the library path to LD_LIBRARY_PATH, assuming CUDA's been installed to a non-standard directory.
* Set the <tt>CUDA_INSTALL_PATH</tt> and <tt>ROOTDIR</tt> (yeargh!) if outside the SDK.
* I keep the following in <tt>bin/cudasetup</tt> of my home directory. Source it, using sh's <tt>. cudasetup</tt> syntax:
<pre>CUDA="$HOME/local/cuda/"
export CUDA_INSTALL_PATH="$CUDA"
export ROOTDIR="$CUDA/C/common/"
if [ -n "$LD_LIBRARY_PATH" ] ; then
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA/lib64"
else
export "LD_LIBRARY_PATH=$CUDA/lib64"
fi
unset CUDA</pre>
* Set EXECUTABLE in your Makefile, and include <tt>$CUDA_INSTALL_PATH/C/common/common.mk</tt>
====Unit testing====
The <tt>DEFAULT_GOAL</tt> special variable of [[GNU Make]] can be used:
<pre>.PHONY: test
.DEFAULT_GOAL:=test
include $(CUDA_INSTALL_PATH)/C/common/common.mk
test: $(TARGET)
        $(TARGET)</pre>
==Libraries==
Two mutually exclusive means of driving CUDA are available: the "Driver API" and "C for CUDA" with its accompanying <tt>nvcc</tt> compiler and runtime. The latter (<tt>libcudart</tt>) is built atop the former, and requires its <tt>libcuda</tt> library.
==CUDA model==
==CUDA model==
===Host===
===Host===
Line 209: Line 147:
|-
|-
|}
|}
==Installation on [[Debian]]==
[http://packages.debian.org/sid/libdevel/libcuda1-dev libcuda-dev] packages exist in the <tt>non-free</tt> archive area, and supply the core library <tt>libcuda.so</tt>. Together with the upstream toolkit and SDK from NVIDIA, this provides a full CUDA development environment for 64-bit Debian Unstable systems. I installed CUDA 2.3 on 2010-01-25 (hand-rolled 2.6.32.6 kernel, built with gcc-4.4). This machine did not have CUDA-compatible hardware (it uses [[Intel 965]]).
* Download the Ubuntu 9.04 files from NVIDIA's "[http://www.nvidia.com/object/cuda_get.html CUDA Zone]".
* Run the toolkit installer (<tt>sh cudatoolkit_2.3_linux_64_ubuntu9.04.run</tt>)
** For a user-mode install, supply <tt>$HOME/local</tt> or somesuch
<pre>* Please make sure your PATH includes /home/dank/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH
*  for 32-bit Linux distributions includes /home/dank/local/cuda/lib
*  for 64-bit Linux distributions includes /home/dank/local/cuda/lib64
* OR
*  for 32-bit Linux distributions add /home/dank/local/cuda/lib
*  for 64-bit Linux distributions add /home/dank/local/cuda/lib64
* to /etc/ld.so.conf and run ldconfig as root
* Please read the release notes in /home/dank/local/cuda/doc/


* To uninstall CUDA, delete /home/dank/local/cuda
* Installation Complete</pre>
* Run the SDK installer (<tt>sh cudasdk_2.3_linux.run</tt>)
** I just installed it to the same directory as the toolkit, which seems to work fine.
<pre>========================================
Configuring SDK Makefile (/home/dank/local/cuda/shared/common.mk)...
========================================
* Please make sure your PATH includes /home/dank/local/cuda/bin
* Please make sure your LD_LIBRARY_PATH includes /home/dank/local/cuda/lib
* To uninstall the NVIDIA GPU Computing SDK, please delete /home/dank/local/cuda
* Installation Complete</pre>
==Building CUDA Apps==
===<tt>nvcc</tt> flags===
* <tt>-ptax-options=-v</tt> displays per-thread register usage
===SDK's common.mk===
This assumes use of the SDK's common.mk, as recommended by the documentation.
* Add the library path to LD_LIBRARY_PATH, assuming CUDA's been installed to a non-standard directory.
* Set the <tt>CUDA_INSTALL_PATH</tt> and <tt>ROOTDIR</tt> (yeargh!) if outside the SDK.
* I keep the following in <tt>bin/cudasetup</tt> of my home directory. Source it, using sh's <tt>. cudasetup</tt> syntax:
<pre>CUDA="$HOME/local/cuda/"
export CUDA_INSTALL_PATH="$CUDA"
export ROOTDIR="$CUDA/C/common/"
if [ -n "$LD_LIBRARY_PATH" ] ; then
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA/lib64"
else
export "LD_LIBRARY_PATH=$CUDA/lib64"
fi
unset CUDA</pre>
* Set EXECUTABLE in your Makefile, and include <tt>$CUDA_INSTALL_PATH/C/common/common.mk</tt>
====Unit testing====
The <tt>DEFAULT_GOAL</tt> special variable of [[GNU Make]] can be used:
<pre>.PHONY: test
.DEFAULT_GOAL:=test
include $(CUDA_INSTALL_PATH)/C/common/common.mk
test: $(TARGET)
        $(TARGET)</pre>
==Libraries==
Two mutually exclusive means of driving CUDA are available: the "Driver API" and "C for CUDA" with its accompanying <tt>nvcc</tt> compiler and runtime. The latter (<tt>libcudart</tt>) is built atop the former, and requires its <tt>libcuda</tt> library.
==deviceQuery info==
==deviceQuery info==
===Compute capability 2.0===
===Compute capability 2.0===