我正在尝试使用 Cuda 启动 shell。我有以下 shell.nix 文件
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
name = "cuda-env-shell";
buildInputs = with pkgs; [
unzip
# other packages
cudatoolkit
# other packages
binutils
];
}
但这由于以下错误而失败。我以前曾遇到过像 davinci-resolve 这样的大文件的情况。对于 davinci-resolve,我的解决方案是使用具有 10 个连接的 axel 创建一个新的 flake,并且每次都运行良好。现在我正面临着 Cuda 的这个问题。
[1/0/3 built, 4 copied (183.8/183.8 MiB), 42.8 MiB DL] building cuda_11.8.0_520.61.05_linux.run: Dload Upload Total Spent Left
error: builder for '/nix/store/idz14mzbsv4k5v5ims095jcjk2r50glr-cuda_11.8.0_520.61.05_linux.run.drv' failed with exit code 1;
last 7 log lines:
>
> trying https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 49 4135M 49 2044M 0 0 772k 0 1:31:20 0:45:08 0:46:12 0
> curl: (56) Recv failure: Connection reset by peer
我想要 Cuda,但是我可以使用 axel 而不是curl 检索 src 吗?我尝试了类似以下的操作,但它似乎不是有效的语法?
cudatoolkit.overrideAttrs
(finalAttrs: previousAttrs: {
pname = previousAttrs.pname + "-bar";
src = runCommandLocal "${previousAttrs.pname}.run" rec { } ''
axel \
--num-connections=10 \
--verbose \
--insecure \
--output $out \
"https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
'';
})
错误:
at /nix/store/0g53xyh39z3y90p4d8r341wbqyjy1zhl-source/pkgs/stdenv/generic/make-derivation.nix:395:7:
394| depsHostHost = elemAt (elemAt dependencies 1) 0;
395| buildInputs = elemAt (elemAt dependencies 1) 1;
| ^
396| depsTargetTarget = elemAt (elemAt dependencies 2) 0;
error: Dependency is not of a valid type: element 13 of buildInputs for cuda-env-shell
第一步,需要在表达式两边添加括号
(cudatoolkit.overrideAttrs (finalAttrs: previousAttrs: { .. }))
以避免破坏列表。在第二步中,需要添加一个
outputHash
以使构建器能够接受下载的源。最初,您可以使用触发显示源哈希的错误。在这种情况下,我获得了哈希值:
sha256-kiPErzrr5Ke77Zq9mxY7A6GzS4VfvCtKDRtwasCaWhY=
。最后,需要添加
axel
到执行命令的环境中。由于它仅用于下载源码,因此您可以将其添加nativeBuildInputs
到runCommandLocal
. 此外,您可以axel
在脚本中替换为${pkgs.axel}/bin/axel
.