As Jared mentions in a comment, from the command line:
/usr/local/cuda/bin/nvcc --version) gives the CUDA compiler version (which matches the toolkit version).
From application code, you can query the runtime API version with
or the driver API version with
As Daniel points out, deviceQuery is an SDK sample app that queries the above, along with device capabilities.
As others note, you can also check the contents of the
version.txt using (e.g., on Mac or Linux)
However, if there is another version of the CUDA toolkit installed other than the one symlinked from
/usr/local/cuda, this may report an inaccurate version if another version is earlier in your
PATH than the above, so use with caution.