PytzMLS2018 Software Installation


Python Installation via Anaconda

Anacond is one of several Python distributions. It provide the Python interpreter, together with several Python packages such as numpy, matplotlib, pandas, sciklearn, jupyter etc and sometimes other related tools, such as editors. Additionally, it provides access to over 720 packages that can easily be installed with conda.

To install the Anaconda Python distribution follow the following installation instructions, which provides the Python interpreter and all need packages. We encourage you to install python 3.6.

To install Anaconda in window machine:

  1. Download Anaconda: Visit the Anaconda homepage, then click Download Anaconda from the menu to go to the download page. Choose the download suitable for your platform (Windows, OSX, or Linux): then Choose Python 3.6 Graphical Installer for your machine (whether 32 or 64bit).
  2. Install Anaconda: Double click the downloaded file and follow the installation wizard.
  3. Start Anaconda: After the installation complete you can confirm that your Anaconda Python environment is up to date. Anaconda comes with a suite of graphical tools called Anaconda Navigator. You can start Anaconda Navigator by opening it from your application launcher.

TensorFlow Installation

TensorFlow is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them. The flexible architecture allows you to deploy computation to one or more CPUs or GPUs in a desktop, server, or mobile device with a single AP.

To install tensorflow (cpu) in windows, ubuntu or mac use the following command in anaconda or command prompt.

conda install -c conda-forge tensorflow

Keras Installation

Keras is a Python library that provides a clean and convenient way to create a range of deep learning models on top of powerful libraries such as TensorFlow, Theano or CNTK. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research. Keras allows for easy and fast prototyping (through user friendliness, modularity, and extensibility). Keras was developed and maintained by François Chollet, a Google engineer.

To install keras (cpu) in windows, ubuntu or mac use the following command in anaconda or command prompt.

conda install -c conda-forge keras

Pytorch Installation

Pytorch is python package for GPU-accelerated deep neural network programming from facebook. It is the Python implementation of the Torch machine learning framework. Unlike TensorFlow, PyTorch offers a quick method to modify existing neural networks without having to rebuild the network from scratch and makes it possible easily print Tensors on the screen. For Deep Learning researchers these are important features, since they usually take several iterations to get a Deep Learning implementation right.

To install pytorch in windows, open Anaconda Prompt and type the following command(s).

First install Intel MKL the fastest and most-used Math Library for Intel®-Based Systems. It cccelerate math processing routines, increase application performance. The library accelerates deep learning applications and framework on Intel(R) architecture.

conda install -c intel mkl
  • for CPU only packages:Use this command if your computer does not have GPU
conda install -c peterjc123 pytorch-cpu
  • for Windows 10 and Windows Server 2016, CUDA 8 (Recommended):Use this command if your computer have GPU
conda install -c peterjc123 pytorch
  • for Windows 10 and Windows Server 2016, CUDA 9: Use this command if your computer have GPU
conda install -c peterjc123 pytorch cuda90
  • for Windows 7/8/8.1 and Windows Server 2008/2012, CUDA 8: Use this command if your computer have GPU
conda install -c peterjc123 pytorch_legacy

For Linux and Mac users should follows the instructions in this link or just type the following command to install pytorch-cpu and torchvision packages

conda install pytorch-cpu torchvision -c pytorch

PIllow and Torchvision windows installation

The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. Pillow is the friendly wraper for PIL Python Imaging Library. These packages are very useful for computer vision task.

To install these package in windows type the following command in anaconda prompt.

conda install -c anaconda pillow
pip install torchvision

TQDM

TqdmA is a fast, extensible progress bar for Python and CLI. It displays statistics and uses smart algorithms to predict and automagically adapt to a variety of use cases with no or minimal configuration. To install this package type the following command in anaconda prompt.

conda install -c conda-forge tqdm

Biopython

Biopython is a set of freely available tools for biological computation written in Python. It is a distributed collaborative effort to develop Python libraries and applications which address the needs of current and future work in bioinformatics. To install this package type the following command in anaconda prompt.

conda install -c anaconda biopython 

Test installation

Create a script that prints the version numbers of each library as follows:

# numpy
import numpy
print('numpy: %s' % numpy.__version__)
# matplotlib
import matplotlib
print('matplotlib: %s' % matplotlib.__version__)
# pandas
import pandas
print('pandas: %s' % pandas.__version__)
# scikit-learn
import sklearn
print('sklearn: %s' % sklearn.__version__)
# tensorflow
import tensorflow
print('tensorflow: %s' % tensorflow.__version__)
# keras
import keras
print('keras: %s' % keras.__version__)
# pytorch
import torch
print('torch: %s' % torch.__version__)
# torchvision
import torchvision
print('torchvision name: %s' % torchvision.__name__)
# pillow
import PIL
print('PIL: %s' % PIL.__version__)
# tqdm
import tqdm
print('tqdm: %s' % tqdm.__version__)

Open conda prompt and type jupyter notebook --port=8890. Create new notebook and paste above codes. Click run to test installion.

Alternatively you can save the script to a file installation_test.py and run it in command prompt by typing:

python installation_test.py

Set Sublime text as Python IDE (optional)

Sublime Text is lightweight, cross-platform code editor known for its speed, ease of use, and strong community support. It’s an incredible editor right out of the box, but the real power comes from the ability to enhance its functionality using Package Control and creating custom settings.

To set-up Sublime Text as full-stack Python development IDE follow the following instruction.

References

  1. How to Setup a Python Environment for Machine Learning and Deep Learning with Anaconda

Back to blog