Linux Documentation

Tensorflow

The tensorflow that you pip install if you ohhh so diligently follow the instructions on tensorflow is designed to work with any CPU. As a result it misses many optimisations available to you specific CPU. These optimisation can speed your code up by a factor of ×3.\times 3. To this end our CPU manufacturer, intel, has created a both a python and tensorflow build with these optimisations of each of its CPUs.

To setup a conda environment with the intel version of python use

conda create -n <name> -c intel intelpython3_full

Then we install tensorflow via

pip install intel-tensorflow

To setup Jupyter notebooks use

conda install jupyter -c intel

Source

Bash Aliases, Functions and FIGNORE

Bash aliases make using the command line a more fluid experience by allowing you to execute a long command by typing a short alias. For example suppose that you are particularly lazy and hate the having to stage ., commit and push changes across three commands then it is possible to define a single command to do all three at once, git-lazy.

To define aliases we should :

  1. Create an file at ~/bash_aliases.sh.

  2. Add the line below code to ~/.bashrc, so that the commands you define in ~/bash_aliases.sh will be loaded when ~/.bashrc is sourced.

if [ -f ~/bash_aliases.sh ]; then
    . ~/bash_aliases.sh
fi
  1. Define your aliases in ~/bash_aliases.sh using the syntax

    alias <alias>='<command>'
    

    where <command> is the command you wish to shorten and <alias> is the short-hand alias you wish to assign it to. You can also define bash functions here.

  2. Finally, so that either you must source ~/.bashrc. This happens automatically every time a terminal is opened, but to avoid having to reopen the terminal you can source it manually with the command

    source ~/.bashrc
    

As an example a alias to open ~/bash_aliases.sh in our favourite text editor gedit then source ~/bash_aliases.sh when we close gedit would be

alias edit-aliases='
gedit ~/.bash_aliases.sh; 
printf "Sourcing ~/.bashrc \n";
source ~/.bashrc
'

The git-lazy command discussed above is better suited to a bash function owing the the necessity of a git commit message.

function git-lazy() {
    git stage .
    git commit -a -m "$1"
    git push
}

Such a function uses the first argument as the commit message. For example git-lazy 'commit message' will stage all changes in the directory, commit them with the commit message 'commit message'then push them to the relevant remote.

The final thing you can do in ~/bash_aliases.sh is set file paths to be ignored with terminal auto-complete. This is achieved with the FIGNORE command followed by a colon separated list of file names to ignore. For example if we wished to ignore all the files autogenerated by the latex compiler the command would be

FIGNORE=".log:.bbl:.aux:.blg:.toc:.out"

[Barnaby]

results matching ""

    No results matching ""