Merge pull request #103292 from mikesperber/libtensorflow-2

libtensorflow_2: add TensorFlow 2 as a library
This commit is contained in:
Jörg Thalheim 2021-01-13 16:39:16 +00:00 committed by GitHub
commit 9de67acaa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 26 deletions

View File

@ -6,25 +6,20 @@
with stdenv.lib;
let
unavailable = throw "libtensorflow is not available for this platform!";
broken = !stdenv.isLinux && !stdenv.isDarwin;
tfType = if cudaSupport then "gpu" else "cpu";
system =
if stdenv.isLinux then "linux"
else if stdenv.isDarwin then "darwin"
else unavailable;
system =
if stdenv.isLinux then "linux"
else "darwin";
platform =
if stdenv.isx86_64 then "x86_64"
else unavailable;
platform = "x86_64";
rpath = makeLibraryPath ([stdenv.cc.libc stdenv.cc.cc.lib] ++
optionals cudaSupport [ cudatoolkit.out cudatoolkit.lib cudnn nvidia_x11 ]);
rpath = makeLibraryPath ([stdenv.cc.libc stdenv.cc.cc.lib]
++ optionals cudaSupport [ cudatoolkit.out cudatoolkit.lib cudnn nvidia_x11 ]);
packages = import ./binary-hashes.nix;
packageName = "${tfType}-${system}-${platform}";
url = packages.${packageName} or unavailable;
patchLibs =
if stdenv.isDarwin
@ -44,7 +39,7 @@ in stdenv.mkDerivation rec {
pname = "libtensorflow";
inherit (packages) version;
src = fetchurl url;
src = fetchurl packages."${tfType}-${system}-${platform}";
nativeBuildInputs = optional cudaSupport addOpenGLRunpath;
@ -72,6 +67,5 @@ in stdenv.mkDerivation rec {
homepage = "https://www.tensorflow.org/install/lang_c";
license = licenses.asl20;
platforms = [ "x86_64-linux" "x86_64-darwin" ];
maintainers = with maintainers; [ basvandijk ];
};
}

View File

@ -1,15 +1,15 @@
{
version = "1.14.0";
cpu-linux-x86_64 = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.14.0.tar.gz";
sha256 = "04bi3ijq4sbb8c5vk964zlv0j9mrjnzzxd9q9knq3h273nc1a36k";
version = "2.4.0";
"cpu-linux-x86_64" = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.4.0.tar.gz";
sha256 = "022p5jjwmb8rhyyis3cpk2lw45apl2vz49m2rgxmd75h783x1gjk";
};
gpu-linux-x86_64 = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.14.0.tar.gz";
sha256 = "1ffnpyj9jjgwxpjfiyjvq4dm3n6nwiksim5jld9zw7fdswh215x6";
"gpu-linux-x86_64" = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.4.0.tar.gz";
sha256 = "1fclvbrn3fs8qmhmh3lzni7s7wl1w30a071b4gzh9ifnxdhip6lq";
};
cpu-darwin-x86_64 = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.14.0.tar.gz";
sha256 = "0zsd5ils1a17j6jzh0c7q1z56fw46gkzybbnms7h2rgg8al0rh92";
"cpu-darwin-x86_64" = {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.4.0.tar.gz";
sha256 = "09x096nslg04c8sr7bd5v68a5gfinc0f1h36lbzn8bahs8b1agi3";
};
}

View File

@ -1,7 +1,9 @@
#!/usr/bin/env bash
version=1.14.0
hashfile=binary-hashes.nix
# ./prefetcher.sh 2.4.0 binary-hashes.nix
version="$1"
hashfile="$2"
rm -f $hashfile
echo "{" >> $hashfile
echo "version = \"$version\";" >> $hashfile