CUDA-12.8.1

Introduction to CUDA

The CUDA proprietary toolkit provides tools for running code on NVIDIA GPUs. This is otherwise known as hardware acceleration.

[Note]

Note

The download size is over 5G, 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.

Additional Downloads

CUDA Dependencies

Required

NVIDIA

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-12.8.1 &&
ln -sfv cuda-12.8.1 /opt/cuda

Install CUDA by running the following commands as the root user:

sh cuda_12.8.1_570.124.06_linux.run \
  --target cuda_12.8.1_570.124.06_linux \
  --noexec &&
pushd cuda_12.8.1_570.124.06_linux/builds &&
  rm -rvf bin integration NVIDIA*.run &&
  mv version.json /opt/cuda-12.8.1 &&
  mkdir -p /opt/cuda-12.8.1/bin &&
  cuda_components=(
    cuda_nsight/{bin,nsightee_plugins},
    cuda_nvvp/{bin,libnvvp},
    cuda_sanitizer_api/compute-sanitizer,
    nsight_compute,
    nsight_systems
  )
  for i in ${cuda_components[@]}; do
    cp -vR $i /opt/cuda-12.8.1
  done &&
  rm -rf cuda_nvvp cuda_nsight cuda_sanitizer_api &&
  ln -sfv ../compute-sanitizer/compute-sanitizer \
    /opt/cuda-12.8.1/bin/compute-sanitizer &&
  mv EULA.txt /opt/cuda-12.8.1 &&
  for lib in *; do
    cp -vR $lib/* /opt/cuda-12.8.1 &&
    rm -rf $lib
  done &&
  ln -svf lib64 /opt/cuda-12.8.1/lib &&
  for mf in $(find /opt/cuda-12.8.1 -name Makefile); do
    sed -i "s|/usr/local/cuda|/opt/cuda-12.8.1|g" "$mf"
  done &&
popd &&
rm -rf cuda_12.8.1_570.124.06_linux
[Note]

Note

The above instructions extract the runfile and installs components manually. In the past, this was not needed. However, cuda_installer fails to load as it relies on an older libxml2 ABI. This process will be kept even when the ABI gets fixed as it allows for more control, despite being more complicated.

Still as the root user, allow the use of new compilers:

sed -e "/.*unsupported GNU version.*/d" \
    -e "/.*unsupported clang version.*/d" \
    -i /opt/cuda-12.8.1/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.

Finally, patch a header file to fix building against glibc-2.41, again as the root user:

patch -Np1 /opt/cuda-12.8.1/targets/x86_64-linux/include/crt/math_functions.h \
  -i cuda-12.8.1-glibc-2.41-1.patch

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

Immediately after installation, update the current PATH for your current shell:

source /etc/profile.d/cuda.sh

Contents

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