这应该很简单,pacman 搜索它,如果没有,yay 搜索它,如果没有,尝试找到它的其他 AUR。如果这些都不起作用,请使用 Nvidia 的官方二进制 blob。
除了没有 CUDA 11.7 的 AUR 版本,也没有任何与 Arch 兼容的 Nvidia 二进制安装程序或二进制包。Debian 的 11.7 CUDA 安装程序可以在 Debian 系统上运行(我已经测试过了),但它在 Arch Linux 上不起作用,它会出现与编译器和其他问题相关的各种错误(如果你强制编译器使用 --override)。
如何在 Arch Linux 上获取 CUDA 11.7?
答案1
您可以使用官方 cuda 软件包的旧版本。它具有很少的依赖项(对于 cuda 11.8 gcc11
,需要opencl-nvidia
、nvidia-utils
和python
),因此在较新的系统上安装它应该可以工作。
您可以在以下位置找到旧的二进制包Arch Linux 档案:https://archive.archlinux.org/packages/c/cuda/并使用sudo pacman -U <package file>
您还可以构建该软件包的旧版本。这样,您就可以将旧版 cuda 与其他版本一起安装。
例如我按照以下步骤安装了cuda 11.8:
- 克隆 cuda 包存储库:
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/cuda.git
cd cuda
- 找到你想要的版本
git tag --list
- 将该版本加载到您的工作树中:(
git switch --detach 11.8.0-1
或git checkout 11.8.0-1
) - 如果需要,请进行编辑
PKGBUILD
。我已更改软件包名称以避免与官方软件包冲突,更改了安装路径,并禁用了与官方软件包冲突的文件的安装(与pkgconfig
或 中相关的任何文件/etc
)。以下是差异:
diff --git a/PKGBUILD b/PKGBUILD
index e688b4c..0cffc67 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,9 +1,9 @@
# Maintainer: Sven-Hendrik Haase <[email protected]>
# Maintainer: Konstantin Gizdov <[email protected]>
-pkgname=(cuda cuda-tools)
-pkgbase=cuda
+pkgname=(cuda11.8 cuda-tools11.8)
+pkgbase=cuda11.8
pkgver=11.8.0
_driverver=520.61.05
pkgrel=1
pkgdesc="NVIDIA's GPU programming toolkit"
arch=('x86_64')
@@ -83,84 +83,84 @@ build() {
local _prepdir="${srcdir}/prep"
cd "${srcdir}/builds"
rm -r NVIDIA*.run bin
- mkdir -p "${_prepdir}/opt/cuda/extras"
- mv integration nsight_compute nsight_systems EULA.txt "${_prepdir}/opt/cuda"
- mv cuda_demo_suite/extras/demo_suite "${_prepdir}/opt/cuda/extras/demo_suite"
- mv cuda_sanitizer_api/compute-sanitizer "${_prepdir}/opt/cuda/extras/compute-sanitizer"
+ mkdir -p "${_prepdir}/opt/cuda11.8/extras"
+ mv integration nsight_compute nsight_systems EULA.txt "${_prepdir}/opt/cuda11.8"
+ mv cuda_demo_suite/extras/demo_suite "${_prepdir}/opt/cuda11.8/extras/demo_suite"
+ mv cuda_sanitizer_api/compute-sanitizer "${_prepdir}/opt/cuda11.8/extras/compute-sanitizer"
rmdir cuda_sanitizer_api
for lib in *; do
if [[ "$lib" =~ .*"version.json".* ]]; then
continue
fi
- cp -r $lib/* "${_prepdir}/opt/cuda/"
+ cp -r $lib/* "${_prepdir}/opt/cuda11.8/"
done
# Delete some unnecessary files
- rm -r "${_prepdir}"/opt/cuda/bin/cuda-uninstaller
+ rm -r "${_prepdir}"/opt/cuda11.8/bin/cuda-uninstaller
# Define compilers for CUDA to use.
# This allows us to use older versions of GCC if we have to.
- ln -s /usr/bin/gcc-11 "${_prepdir}/opt/cuda/bin/gcc"
- ln -s /usr/bin/g++-11 "${_prepdir}/opt/cuda/bin/g++"
+ ln -s /usr/bin/gcc-11 "${_prepdir}/opt/cuda11.8/bin/gcc"
+ ln -s /usr/bin/g++-11 "${_prepdir}/opt/cuda11.8/bin/g++"
# Install profile and ld.so.config files
- install -Dm755 "${srcdir}/cuda.sh" "${_prepdir}/etc/profile.d/cuda.sh"
- install -Dm644 "${srcdir}/cuda.conf" "${_prepdir}/etc/ld.so.conf.d/cuda.conf"
+ #install -Dm755 "${srcdir}/cuda.sh" "${_prepdir}/etc/profile.d/cuda.sh"
+ #install -Dm644 "${srcdir}/cuda.conf" "${_prepdir}/etc/ld.so.conf.d/cuda.conf"
# Install pkgconfig files
- mkdir -p "$_prepdir"/usr/lib/pkgconfig
- cp "${srcdir}"/*.pc "${_prepdir}"/usr/lib/pkgconfig
+ #mkdir -p "$_prepdir"/usr/lib/pkgconfig
+ #cp "${srcdir}"/*.pc "${_prepdir}"/usr/lib/pkgconfig
mkdir -p "${_prepdir}/usr/share/licenses/${pkgname}"
- ln -s /opt/cuda/EULA.txt "${_prepdir}/usr/share/licenses/${pkgname}/EULA.txt"
- ln -s /opt/cuda/README "${_prepdir}/usr/share/licenses/${pkgname}/README"
+ ln -s /opt/cuda11.8/EULA.txt "${_prepdir}/usr/share/licenses/${pkgname}/EULA.txt"
+ ln -s /opt/cuda11.8/README "${_prepdir}/usr/share/licenses/${pkgname}/README"
# Allow newer compilers to work. This is not officially supported in the Arch package but
# if users want to try, let them try.
# See https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements
# for official requirements
- sed -i "/.*unsupported GNU version.*/d" "${_prepdir}"/opt/cuda/targets/x86_64-linux/include/crt/host_config.h
- sed -i "/.*unsupported clang version.*/d" "${_prepdir}"/opt/cuda/targets/x86_64-linux/include/crt/host_config.h
+ sed -i "/.*unsupported GNU version.*/d" "${_prepdir}"/opt/cuda11.8/targets/x86_64-linux/include/crt/host_config.h
+ sed -i "/.*unsupported clang version.*/d" "${_prepdir}"/opt/cuda11.8/targets/x86_64-linux/include/crt/host_config.h
# Fix Makefile paths to CUDA
- for f in $(find "$_prepdir"/opt/cuda -name Makefile); do
- sed -i "s|/usr/local/cuda|/opt/cuda|g" "$f"
+ for f in $(find "$_prepdir"/opt/cuda11.8 -name Makefile); do
+ sed -i "s|/usr/local/cuda|/opt/cuda11.8|g" "$f"
done
}
-package_cuda() {
+package_cuda11.8() {
replaces=('cuda-toolkit' 'cuda-sdk' 'cuda-static')
provides=('cuda-toolkit' 'cuda-sdk' 'libcudart.so' 'libcublas.so' 'libcusolver.so' 'libcusparse.so')
optdepends=('gdb: for cuda-gdb'
'glu: required for some profiling tools in CUPTI')
local _prepdir="${srcdir}/prep"
cd "${_prepdir}"
cp -al * "${pkgdir}"
# remove broken links
- rm "${pkgdir}"/opt/cuda/include/include
- rm "${pkgdir}"/opt/cuda/lib64/lib64
+ rm "${pkgdir}"/opt/cuda11.8/include/include
+ rm "${pkgdir}"/opt/cuda11.8/lib64/lib64
- rm -r "${pkgdir}"/opt/cuda/{bin/nvvp,bin/computeprof,libnvvp,nsight*}
+ rm -r "${pkgdir}"/opt/cuda11.8/{bin/nvvp,bin/computeprof,libnvvp,nsight*}
}
-package_cuda-tools() {
+package_cuda-tools11.8() {
pkgdesc="NVIDIA's GPU programming toolkit (extra tools: nvvp, nsight)"
depends=('cuda' 'java-runtime=8' 'nss')
optdepends=('perl: required by some NVVP plugins')
local _prepdir="${srcdir}/prep"
- mkdir -p "${pkgdir}/opt/cuda/bin"
- mv "${_prepdir}"/opt/cuda/nsight* "${pkgdir}/opt/cuda"
- mv "${_prepdir}"/opt/cuda/bin/nvvp "${pkgdir}/opt/cuda/bin/nvvp"
- mv "${_prepdir}"/opt/cuda/bin/computeprof "${pkgdir}/opt/cuda/bin/computeprof"
- mv "${_prepdir}"/opt/cuda/libnvvp "${pkgdir}/opt/cuda"
+ mkdir -p "${pkgdir}/opt/cuda11.8/bin"
+ mv "${_prepdir}"/opt/cuda11.8/nsight* "${pkgdir}/opt/cuda11.8"
+ mv "${_prepdir}"/opt/cuda11.8/bin/nvvp "${pkgdir}/opt/cuda11.8/bin/nvvp"
+ mv "${_prepdir}"/opt/cuda11.8/bin/computeprof "${pkgdir}/opt/cuda11.8/bin/computeprof"
+ mv "${_prepdir}"/opt/cuda11.8/libnvvp "${pkgdir}/opt/cuda11.8"
# licenses
mkdir -p "${pkgdir}/usr/share/licenses"
ln -s /usr/share/licenses/cuda "${pkgdir}/usr/share/licenses/${pkgname}"
}
- 使用以下方式构建包
makepkg
- 使用
sudo pacman -U cuda11.8-11.8.0-1-x86_64.pkg.tar.zst
和安装sudo pacman -U cuda-tools11.8-11.8.0-1-x86_64.pkg.tar.zst
- 更改shell 中的
PATH
和CUDA_HOME
,以便其他软件使用此版本:
export PATH="/opt/cuda11.8/bin:$PATH"
export CUDA_HOME="/opt/cuda11.8"