cudaversioningapi-versioningcuda-driver

Are CUDA_VERSION and CUDART_VERSION necessarily the same?


The CUDA Driver API defines CUDA_VERSION (in cuda.h), and the CUDA Runtime API defines CUDART_VERSION (in cuda_runtime_api.h). However - CUDART_VERSION is not defined as CUDA_VERSION but directly as a number.

Are they always supposed to have the exact same value, or are there circumstances in which they might differ?


Solution

  • They will be the same observationally, but not linked.

    As you already know at runtime, the CUDA version can be different than the CUDART version. Therefore (or, insofar as that answer describes) there is no connection between the two.

    However, both cuda.h and cuda_runtime_api.h will be installed by a CUDA installer. So with respect to what that installer installs, they will match. The installer installs both a driver and a development environment where the CUDA (driver API) version and CUDA runtime API version match. But later on that can change (if you update the driver, for example.) That is to say, the runtime versions can change depending on subsequent install activity. In any event, the cuda.h installed by the CUDA toolkit installer and the cuda_runtime_api.h installed by the CUDA toolkit installer will be as installed by the toolkit installer.

    cuda_runtime_api.h does not depend on cuda.h. For that reason, one define is not simply a define of the other. You can build CUDA runtime API applications that don't depend on cuda.h (the deviceQuery sample code is an example) and so there is no reason for cuda_runtime_api.h to build a define based on something in cuda.h - that would require you to always include cuda.h whenever you include cuda_runtime_api.h, and the CUDA designers had no intention of that.