2021-04-08 16:26:57 +00:00
|
|
|
{ lib, stdenv, fetchurl, autoPatchelfHook, python3 }:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "gpt2tc";
|
2021-05-28 09:39:13 +00:00
|
|
|
version = "2021-04-24";
|
2021-04-08 16:26:57 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2023-02-16 17:41:37 +00:00
|
|
|
url = "https://web.archive.org/web/20220603034455/https://bellard.org/libnc/gpt2tc-2021-04-24.tar.gz";
|
|
|
|
hash = "sha256-6oTxnbBwjHAXVrWMjOQVwdODbqLRoinx00pi29ff5w0=";
|
2021-04-08 16:26:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Add a shebang to the python script so that nix detects it as such and
|
|
|
|
# wraps it properly. Otherwise, it runs in shell and freezes the system.
|
|
|
|
./0001-add-python-shebang.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ autoPatchelfHook ];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
(python3.withPackages (p: with p; [ numpy tensorflow ]))
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
install -D -m755 -t $out/lib libnc${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
addAutoPatchelfSearchPath $out/lib
|
2021-04-08 16:26:57 +00:00
|
|
|
install -D -m755 -t $out/bin gpt2tc
|
|
|
|
install -T -m755 download_model.sh $out/bin/gpt2-download-model
|
|
|
|
install -T -m755 gpt2convert.py $out/bin/gpt2-convert
|
|
|
|
install -D -m644 -t $out/share/gpt2tc readme.txt gpt2vocab.txt Changelog
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Text completion and compression using GPT-2";
|
2022-02-10 20:34:41 +00:00
|
|
|
homepage = "https://bellard.org/libnc/gpt2tc.html";
|
2022-07-14 12:49:19 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2021-04-08 16:26:57 +00:00
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ anna328p ];
|
|
|
|
};
|
|
|
|
}
|