Tensorflow: Difference between revisions

From NixOS Wiki
imported>Mjlbach
Created page with "== Tensorflow == There some possible ways to install tensorflow. Nixpkgs provides multiiple versions, however, it is often desirable to be able to install the latest nightly..."
 
imported>Mjlbach
mNo edit summary
Line 5: Line 5:
* By making a nix-shell
* By making a nix-shell


{{file|tensorflow-cuda-shell.nix|nix|<nowiki>
<syntaxhighlight lang="nix">
with import <nixpkgs> {};
with import <nixpkgs> {};
mkShell {
mkShell {
Line 22: Line 22:
   '';
   '';
}
}
</nowiki>}}
</syntaxhighlight>


Within this shell, pip install tf-nightly should work and provide GPU support. The cuda toolkit version can be changed to correspond with the matching tensorflow version.
Within this shell, pip install tf-nightly should work and provide GPU support. The cuda toolkit version can be changed to correspond with the matching tensorflow version.

Revision as of 17:16, 11 February 2020

Tensorflow

There some possible ways to install tensorflow. Nixpkgs provides multiiple versions, however, it is often desirable to be able to install the latest nightly from pip. This can accomplished in the following ways:

  • By making a nix-shell
with import <nixpkgs> {};
mkShell {
  name = "tensorflow-cuda-shel";
  buildInputs = with python3.pkgs; [
    pip
    numpy
    setuptools
  ];
  shellHook = ''
    export LD_LIBRARY_PATH=${pkgs.linuxPackages.nvidia_x11}/lib:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.cudatoolkit_10_1}/lib:${pkgs.cudnn_cudatoolkit_10_1}/lib:${pkgs.cudatoolkit_10_1.lib}/lib:$LD_LIBRARY_PATH
    alias pip="PIP_PREFIX='$(pwd)/_build/pip_packages' TMPDIR='$HOME' \pip"
    export PYTHONPATH="$(pwd)/_build/pip_packages/lib/python3.7/site-packages:$PYTHONPATH"
    export PATH="$(pwd)/_build/pip_packages/bin:$PATH"
    unset SOURCE_DATE_EPOCH
  '';
}

Within this shell, pip install tf-nightly should work and provide GPU support. The cuda toolkit version can be changed to correspond with the matching tensorflow version.

See also