How to use Keras, Python and Jupyter on the IFI workstations
Here's some instructions to run a completely local Python/Keras environment on the IFI Linux workstations. These computers are great, but don't have Keras, so we need to do some extra work to set them up for our purposes.
Python installations are complicated an use lots of packages so developers often make "virtual" python environments to keep the packages they need separate from ones that are used by default in the operating system. To do this, you need the virtualenv
command that can create one of these environments (this command isn't installed on the IFI Fedora systems unfortunately.
The first step is to install the virtualenv
tool:
pip3 install --user virtualenv
This installs virtualenv
in your home directory under ~/.local/bin/
.
Now you can follow the Tensorflow Linux Install Instructions, however, instead of typing virtualenv
, you have to type ~/.local/bin/virtualenv
.
Here's the setup, this builds a virtual python environment for python3 called 'venv' in a folder called 'tensorflow' (nb, those names are indicative only, you might want to have lots of virtualenvs with different names...)
mkdir ~/in5490keras
cd ~/in5490keras
~/.local/bin/virtualenv -p python3 venv
Now we activate the virtual python environment usin the source
command:
source ~/in5490/venv/bin/activate
You'll know that your environment is working because you'll have a little (venv)
indicator before your username in the terminal, like so:
(venv) [charlepm@krol in5490keras]$
Now that your virtual environment is active you can use the python
and pip
commands and it will use your local python setup rather than the workstation's global python installation. This is great, because you can now install python packages to this directory, and it won't complain about needing root access.
pip install -U pip
pip install -U keras tensorflow scikit-learn jupyter
That last command will take a while and install a lot of packages into your virtual environment (644M).
Now you can operate python as normal (type python
), or use jupyter notebooks to work on your project:
jupyter notebook
Whenever you exit the terminal, your virtualenv is deactivated, so you will have to activate again whenever you want to do some more work on your project. If you find that you need more packages (e.g., pandas
) you can install them into your virtual env as well: pip install -U pandas
Enjoy your new pythonic freedom!
--C