Install Tensorflow and Keras Note (for linux and mac)

by TC 2018/06/26

Install Anaconda

linux DL
linux installation guide

Mac DL
Mac installation guide

For my Ubuntu, it is as simple as running the bash script in terminal,

bash Anaconda3-5.2.0-Linux-x86_64.sh

test

Once it is done, run python in terminal and it will show
"Python 3.6.5 |Anaconda, Inc.|"

bashrc

(optional) Only when there is a old default version of python already installed, we need to edit the bashrc to add path

vim ~/.bashrc export PATH="/home/assimov/anaconda3/bin:$PATH" source ~/.bashrc

Test again until the correct result shows in prompt.

Create an environment using conda and install tensorflow and keras

Open the terminal,

# clone the base env to create an environment called "tensorflowtest" conda create --clone base --name tensorflowtest # activate the environment # note that this specific command in win is different source activate tensorflowtest # check how many libs are included in tensorflowtest conda list # install msgpack # note that there is inconsistency in this new version of tf. # So we need to install this pip install msgpack # install tensorflow pip install tensorflow # install keras pip install keras

tests the installation

  • (1)
    inside the tensorflowtest env,
conda list

should hava tensorflow and keras libs.

  • (2)
    inside the tensorflowtest env,
# prompt python session python # import libs import tensorflow as tf ## No news is good news! Just some minor future warnings are acceptable import keras # if corrects, it will show: Using TensorFlow backend.
Select a repo