CUDA-13.1.0

Introduction to CUDA

This is the CUDA proprietary toolkit, providing tools for running code on Turing through Blackwell NVIDIA GPUs via the r590 NVIDIA driver. This is NVIDIA's approach to hardware acceleration.

[Important]

Important

The NVIDIA driver version listed in the runfile name is the minimum NVIDIA driver version required.

[Note]

Note

The download size is around 4G, so you should consider if and when you will want to download this runfile. For this reason, it is not recommended to download it when using limited hotspot data. Its size can largely be attributed to containing compilers as well as the NVIDIA driver. The driver only accounts for 10% of the runfile's size.

CUDA Dependencies

Required
NVIDIA-590.48.01

Recommended
The Bash Shell Startup Files

Optional
GDB and GLU-9.0.3

Installation of CUDA

First create the installation directory and symlink as the root user:

mkdir -pv /opt/cuda-13.1.0 &&
ln -sfv cuda-13.1.0 /opt/cuda
[Note]

Note

When installing multiple packages in a script, the installation needs to be done as the root user. There are three general options that can be used to do this:

  1. Run the entire script as the root user (not recommended).

  2. Use the sudo command from the sudo package.

  3. Use su -c "command arguments" (quotes required) which will ask for the root password for every iteration of the loop.

One way to handle this situation is to create a short bash function that automatically selects the appropriate method. Once the command is set in the environment, it does not need to be set again.

as_root()
{
  if   [ $EUID = 0 ];        then $*
  elif [ -x /usr/bin/sudo ]; then sudo $*
  else                            su -c \\"$*\\"
  fi
}

export -f as_root

Start a subshell that will exit on an error:

bash -e

Install CUDA by running the following commands:

sh cuda_13.1.0_590.44.01_linux.run     \
  --target cuda_13.1.0_590.44.01_linux \
  --noexec
pushd cuda_13.1.0_590.44.01_linux/builds
  rm -rf cuda_nsight cuda_sanitizer_api nsight_{compute,systems}
  rm -rvf bin integration NVIDIA*.run
  as_root cp version.json /opt/cuda-13.1.0
  as_root cp EULA.txt     /opt/cuda-13.1.0
  rm version.json EULA.txt
  as_root mkdir -p /opt/cuda-13.1.0/bin
  for lib in *; do
    as_root cp -vR $lib/* /opt/cuda-13.1.0
    rm -rf $lib
  done
  as_root ln -svf lib64 /opt/cuda-13.1.0/lib
  for mf in $(find /opt/cuda-13.1.0 -name Makefile); do
    as_root sed -i "s|/usr/local/cuda|/opt/cuda-13.1.0|g" "$mf"
  done
popd
rm -rf cuda_13.1.0_590.44.01_linux

Now exit the subshell process:

exit

As the root user, allow the use of new compilers:

sed -e "/.*unsupported GNU version.*/d" \
    -e "/.*unsupported clang version.*/d" \
    -i /opt/cuda-13.1.0/targets/x86_64-linux/include/crt/host_config.h
[Important]

Important

This technically is not supported and there may be compilation errors in other packages as a result. However, it's a better compromise than installing older compilers just for one package. This package is still being developed but takes a long time to adapt to newer software.

Command Explanations

--target: This parameter specifies the extraction directory.

--noexec: This parameter does ensures the toolkit does not get triggered for installation.

Configuring CUDA

Ensure the libraries are cached as the root user:

cat > /etc/ld.so.conf.d/cuda.conf << EOF &&
/opt/cuda/lib64
/opt/cuda/nvvm/lib64
/opt/cuda/extras/CUPTI/lib64
EOF

ldconfig

Now in order to use the toolkit, it needs to be included in the path.

As the root user, create the profile (dependent on The Bash Shell Startup Files) for CUDA:

cat > /etc/profile.d/cuda.sh << "EOF"
# Begin /etc/profile.d/cuda.sh

pathprepend /opt/cuda/bin           PATH

# End /etc/profile.d/cuda.sh
EOF

Now source the main profile:

source /etc/profile

Contents

For a full package listing, check Arch's CUDA package contents as the full list is too expansive to list here.