Setup SSH keys. With your SEAS username and password, login to login.seas.harvard.edu via SSH and install SSH keys (Windows users can use
PuTTY or
Cygwin). Follow
these instructions to setup SSH keys.
With the public key properly installed in your home directory (e.g. at login.seas.harvard.edu), you can ssh directly to resonance.seas.harvard.edu. To avoid password logins when accessing GPU nodes from resonance, make sure to enable SSH agent forwarding when you logon; this is an option under Putty, and is invoked with the '-A' option for ssh.
Initiate an interactive session on a GPU-equipped node. To initiate the session, login to resonance and execute the following command:
gpu-login
This will reserve a full compute node (2 GPUs, 4 processor cores) for interactive use, for 1 hour (this setup may change in the future, depending on class size and system usage).
Setup your environment for CUDA. The cluster has a convenient interface for setting up application-specific environments. To add the correct entries to your PATH and LD_LIBRARY_PATH environment variables for development with CUDA and gcc, simply invoke
module load compilers/gcc/4.3.3
module load mpi/openmpi/1.2.8/gnu
module load packages/cuda/2.2
I recommend adding these lines to your ~/.bashrc ~/.bash_profile (updated 09/03/09) file so that you don't have to invoke this at every login
if echo $HOSTNAME | grep -e '\(resonance\|nikola\)\.seas' -e '^cuda'; then
module load compilers/gcc/4.3.3
module load mpi/openmpi/1.2.8/gnu
module load packages/cuda/2.2
fi
(updated 09/10/09)
Install CUDA on your own machine [optional]. While not required for the course, you can also develop CUDA code on your own machine. However note that in the end, all homework submissions must compile and run on the cluster. For those of you that are interested in developing locally, here is
a list of NVIDIA cards that support CUDA and the
main CUDA download page, where you can download the appropriate driver, toolkit, and SDK for your system.
Part 3: Compiling and running a simple CUDA example
Download some example code (
example.cu in
homework0.zip) to your working directory on resonance. This simple example takes an input string from the command line and mangles it according the current system date and time, on both the CPU and GPU. The code demonstrates some simple aspects of CUDA, including device initialization and error checking with libcutil (in the CUDA SDK), transfers between host and device memory, and CUDA kernel invocation.
Compile the code as
nvcc example.cu -o example -I$CUDASDK_HOME/common/inc \
$CUDASDK_HOME/lib/linux -lcutil
nvcc example.cu -o example -I$CUDASDK_HOME/common/inc \
-L$CUDASDK_HOME/lib -lcutil
(updated 09/03/09)
and invoke from the command line:
./example -string="<str>" {-device=<dev>} ,
where <str> is the input string, and, optionally, <dev> is the device number.
For submission, just run the example as
./example -string="<title of your favorite movie" &> example.out
to write the results to example.out,inserting the title of your favorite movie as appropriate.
Part 4: C programming questions