Installing traiNNer using nix
Nix is a packagemanager that allows us to create reproducible virtual environments, no matter what underlying Linux distribution you use.
This guide will walk you through the process of installing traiNNer using nix and specifically nix-shell.
1. We will need to install nix itself.
To do so open any Terminal and enter
sh <(curl -L https://nixos.org/nix/install) --daemon
This will download the nix install script and execute it, just follow the instructions it displays when needed.
2. It's time to download traiNNer, to do so, lets clone it using git. In case you don't have git installed, the following command will make git available in the current Terminal Window until you close it
nix-shell -p git
Then clone traiNNer with
https://github.com/victorca25/traiNNer.git
3. Now that nix and traiNNer are installed, we will create a shell.nix file that declares the dependencies of traiNNer.
Just create a file called shell.nix using your favourite editor and paste the following content into it:
<syntaxhighlight lang="nix">{ pkgs ? import <nixpkgs> {} }: pkgs.mkShell {
nativeBuildInputs = [ pkgs.python310Packages.torchvision pkgs.python310Packages.torch pkgs.python310Packages.pyyaml pkgs.python310Packages.numpy pkgs.python310Packages.opencv4 pkgs.python310Packages.tensorboardx ];
}</syntaxhighlight>
4. Now let's open the environment:
nix-shell shell.nix
The shell.nix part at the end is actually optional, but I like to be explicit. If you gave it another name than shell.nix, say trainner.nix, you will need to specify the name of it instead.
That's it, you should now be able to use traiNNer.