
In this case, the login node will typically not have CUDA installed.Īssuming CUDA was installed on Ubuntu (arguably the most common system for ML/DL), we can use apt to get both CUDA and cuDNN library versions installed in the current (container) system: $ apt list -installed | grep cud
#CHECK UBUNTU VERSION INSTALL#
if thenĮcho "Warning: Installing CPU-only version of pytorch"īut be careful with this because you can accidentally install a CPU-only version when you meant to have GPU support.įor example, if you run the install script on a server's login node which doesn't have GPUs and your jobs will be deployed onto nodes which do have GPUs. Similarly, you could install the CPU version of pytorch when CUDA is not installed. This environment variable is useful for downstream installations, such as when pip installing a copy of pytorch that was compiled for the correct CUDA version. # Determine CUDA version using /usr/local/cuda/version.txt fileĬUDA_VERSION=$(cat /usr/local/cuda/version.txt | sed 's/.* \(\+\.\+\).*/\1/') # Determine CUDA version using /usr/local/cuda/bin/nvcc binaryĬUDA_VERSION=$(/usr/local/cuda/bin/nvcc -version | sed -n 's/^.*release \(\+\.\+\).*$/\1/p') Įlif then # Determine CUDA version using default nvcc binaryĬUDA_VERSION=$(nvcc -version | sed -n 's/^.*release \(\+\.\+\).*$/\1/p') Įlif /usr/local/cuda/bin/nvcc -version 2&> /dev/null then We can combine these three methods together in order to robustly get the CUDA version as follows: if nvcc -version 2&> /dev/null then In this scenario, the nvcc version should be the version you're actually using. Note that sometimes the version.txt file refers to a different CUDA installation than the nvcc -version. The output of which CUDA Version 10.1.243Ĭan be parsed using sed to pick out just the MAJOR.MINOR release version number. The output of which is the same as above, and it can be parsed in the same way.Īlternatively, you can find the CUDA version from the version.txt file.
#CHECK UBUNTU VERSION FULL#
If nvcc isn't on your path, you should be able to run it by specifying the full path to the default location of nvcc instead. We can pass this output through sed to pick out just the MAJOR.MINOR release version number.

The output looks like this: nvcc: NVIDIA (R) Cuda compiler driverĬopyright (c) 2005-2020 NVIDIA CorporationĬuda compilation tools, release 11.0, V11.0.194 If you have multiple versions of CUDA installed, this command should print out the version for the copy which is highest on your PATH. I think this should be your first port of call.
#CHECK UBUNTU VERSION HOW TO#
Here, I'll describe how to turn the output of those commands into an environment variable of the form "10.2", "11.0", etc. Other respondents have already described which commands can be used to check the CUDA version.
