at master 1.3 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p nix-prefetch-scripts 3 4set -eou pipefail 5 6version=$1 7 8bucket="https://download.pytorch.org/libtorch" 9CUDA_VERSION=cu124 10 11url_and_key_list=( 12 "aarch64-darwin-cpu $bucket/cpu/libtorch-macos-arm64-${version}.zip libtorch-macos-arm64-${version}.zip" 13 "x86_64-linux-cpu $bucket/cpu/libtorch-cxx11-abi-shared-with-deps-${version}%2Bcpu.zip libtorch-cxx11-abi-shared-with-deps-${version}-cpu.zip" 14 "x86_64-linux-cuda $bucket/${CUDA_VERSION}/libtorch-cxx11-abi-shared-with-deps-${version}%2B${CUDA_VERSION}.zip libtorch-cxx11-abi-shared-with-deps-${version}-${CUDA_VERSION}.zip" 15) 16 17hashfile="binary-hashes-$version.nix" 18echo " \"$version\" = {" >> $hashfile 19 20for url_and_key in "${url_and_key_list[@]}"; do 21 key=$(echo "$url_and_key" | cut -d' ' -f1) 22 url=$(echo "$url_and_key" | cut -d' ' -f2) 23 name=$(echo "$url_and_key" | cut -d' ' -f3) 24 25 echo "prefetching ${url}..." 26 hash=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $(nix-prefetch-url --unpack "$url" --name "$name")) 27 28 echo " $key = {" >> $hashfile 29 echo " name = \"$name\";" >> $hashfile 30 echo " url = \"$url\";" >> $hashfile 31 echo " hash = \"$hash\";" >> $hashfile 32 echo " };" >> $hashfile 33 34 echo 35done 36 37echo " };" >> $hashfile 38echo "done."