We need to use Keras with TensorFlow as backend for some deep learning projects in the Spark platform we practice data science. The platform we have been using is a CentOS VM running on software based hypervisor called VirtualBox.
Additionally, for future deep learning projects that may use the dataset with Apache Spark, we need to install Theano, Pytorch and Torchvision.
We already have Python 3.6 under virtual environment on Anaconda. Here are the steps:
Enter virtual environment spark
Upgrade pip
Copy pip install pip --upgrade
#Collecting pip
# Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
# |████████████████████████████████| 1.5 MB 2.5 MB/s
#Installing collected packages: pip
# Attempting uninstall: pip
# Found existing installation: pip 20.0.2
# Uninstalling pip-20.0.2:
# Successfully uninstalled pip-20.0.2
#Successfully installed pip-20.1.1
Install TensorFlow
Copy conda install -c conda-forge tensorflow
#Collecting package metadata (current_repodata.json): done
#Solving environment: done
#
## Package Plan ##
#.....
# environment location: /opt/hadoop/anaconda3/envs/spark
# added / updated specs:
# - tensorflow
#....
#Preparing transaction: done
#Verifying transaction: done
#Executing transaction: done
Verify TensorFlow installed successfully
Copy python -c "import tensorflow"
Install Keras
Copy conda install -c conda-forge keras
#Collecting package metadata (current_repodata.json): done
#Solving environment: done
## Package Plan ##
# environment location: /opt/hadoop/anaconda3/envs/spark
# added / updated specs:
# - keras
# The following packages will be downloaded:
# package | build
# ---------------------------|-----------------
# keras-2.4.3 | py_0 30 KB conda-forge
# ------------------------------------------------------------
# Total: 30 KB
#The following NEW packages will be INSTALLED:
# keras conda-forge/noarch::keras-2.4.3-py_0
# Proceed ([y]/n)? y
#Downloading and Extracting Packages
#keras-2.4.3 | 30 KB | ################################################################################################################## | 100%
#Preparing transaction: done
#Verifying transaction: done
#Executing transaction: done
Verify Keras is installed successfully
Copy python -c "import keras"
Install Theano
Copy conda install -c anaconda theano
#Collecting package metadata (current_repodata.json): done
#Solving environment: done
## Package Plan ##
# environment location: /opt/hadoop/anaconda3/envs/spark
# added / updated specs:
# - theano
#...
#Preparing transaction: done
#Verifying transaction: done
#Executing transaction: done
Install Pytorch
Copy conda install -c anaconda pytorch
#Collecting package metadata (current_repodata.json): done
#Solving environment: done
## Package Plan ##
# environment location: /opt/hadoop/anaconda3/envs/spark
# added / updated specs:
# - pytorch
#...
#Preparing transaction: done
#Verifying transaction: done
#Executing transaction: done
Install Torchvision
Copy conda install -c torchvision
#Collecting package metadata (current_repodata.json): done
## Package Plan ##
# environment location: /opt/hadoop/anaconda3/envs/spark
# added / updated specs:
# - torchvision
#...
#Preparing transaction: done
#Verifying transaction: done
#Executing transaction: done
Verify all installation
Copy python
Python 3.6.10 | Anaconda, Inc. | ( default, Mar 25 2020, 23:51:54 )
[GCC 7.3.0] on linux
Type "help" , "copyright" , "credits" or "license" for more information.
>>> import tensorflow
>>> import keras
>>> import theano
>>> import torch
>>> import torchvision
>>> quit ()