Please visit my new personal website. Stay SMART, stay SAFE!
In tensorboard documentation, they import from an api code.
import tensorflow as tf
from tensorboard.plugins.hparams import api as hp
But the details are not there in the api. So github repo of the api code, you can see there are two additional imports are there.
from tensorboard.plugins.hparams import keras
from tensorboard.plugins.hparams import summary_v2
So for detail functionality, go to keras.py (this part is for callback functionality with tensorboard) and summary_v2.py (this part is for hparam definition and functionality).
Use anaconda to start with an empty environment.
knayem@eagles:~/anaconda3$ conda create --name python3.8.5
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/knayem/anaconda3/envs/python3.8.5
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate python3.8.5
#
# To deactivate an active environment, use
#
# $ conda deactivate
Check content of the environment. It should be empty.
knayem@eagles:~/anaconda3$ conda activate python3.8.5
(python3.8.5) knayem@eagles:~/anaconda3$ conda list
# packages in environment at /home/knayem/anaconda3/envs/python3.8.5:
#
# Name Version Build Channel
Now install desired python version for this particular environment, which in my case 3.8.5.
(python3.8.5) knayem@eagles:~/anaconda3$ conda install python==3.8.5
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/knayem/anaconda3/envs/python3.8.5
added / updated specs:
- python==3.8.5
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | main 3 KB
ca-certificates-2020.7.22 | 0 125 KB
certifi-2020.6.20 | py38_0 156 KB
ld_impl_linux-64-2.33.1 | h53a641e_7 568 KB
openssl-1.1.1h | h7b6447c_0 2.5 MB
pip-20.2.2 | py38_0 1.7 MB
python-3.8.5 | h7579374_1 49.3 MB
setuptools-49.6.0 | py38_0 748 KB
zlib-1.2.11 | h7b6447c_3 103 KB
------------------------------------------------------------
Total: 55.2 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
ca-certificates pkgs/main/linux-64::ca-certificates-2020.7.22-0
certifi pkgs/main/linux-64::certifi-2020.6.20-py38_0
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7
libedit pkgs/main/linux-64::libedit-3.1.20191231-h14c3975_1
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_1
openssl pkgs/main/linux-64::openssl-1.1.1h-h7b6447c_0
pip pkgs/main/linux-64::pip-20.2.2-py38_0
python pkgs/main/linux-64::python-3.8.5-h7579374_1
readline pkgs/main/linux-64::readline-8.0-h7b6447c_0
setuptools pkgs/main/linux-64::setuptools-49.6.0-py38_0
sqlite pkgs/main/linux-64::sqlite-3.33.0-h62c20be_0
tk pkgs/main/linux-64::tk-8.6.10-hbc83047_0
wheel pkgs/main/noarch::wheel-0.35.1-py_0
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3
Proceed ([y]/n)? y
Downloading and Extracting Packages
ld_impl_linux-64-2.3 | 568 KB | ######################################################################################################################################################################## | 100%
python-3.8.5 | 49.3 MB | ######################################################################################################################################################################## | 100%
setuptools-49.6.0 | 748 KB | ######################################################################################################################################################################## | 100%
pip-20.2.2 | 1.7 MB | ######################################################################################################################################################################## | 100%
ca-certificates-2020 | 125 KB | ######################################################################################################################################################################## | 100%
zlib-1.2.11 | 103 KB | ######################################################################################################################################################################## | 100%
openssl-1.1.1h | 2.5 MB | ######################################################################################################################################################################## | 100%
_libgcc_mutex-0.1 | 3 KB | ######################################################################################################################################################################## | 100%
certifi-2020.6.20 | 156 KB | ######################################################################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
You can check installed package list again using conda list command. Since pip is already been installed by default, it is a good idea to upgrade pip and install further packages by pip.
(python3.8.5) knayem@eagles:~/anaconda3$ pip -V
pip 20.2.2 from /home/knayem/anaconda3/envs/python3.8.5/lib/python3.8/site-packages/pip (python 3.8)
(python3.8.5) knayem@eagles:~/anaconda3$ pip install --upgrade pip
Collecting pip
Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 5.7 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.2
Uninstalling pip-20.2.2:
Successfully uninstalled pip-20.2.2
Successfully installed pip-20.2.3
It is good idea to add this conda environment to jupyter
(python3.8.5) knayem@eagles:~/anaconda3$ python -m ipykernel install --user --name=python3.8.5
Installed kernelspec python3.8.5 in /home/knayem/.local/share/jupyter/kernels/python3.8.5
If conda command does not work, then try
knayem@eagles:~$ source anaconda3/bin/activate
This should activate base conda environment. If this works, then we can fix the conda command by adding in to .bash_profile
### .bash_profile
export CONDA_ENV_ROOT="$HOME/anaconda3/"
export PATH="$CONDA_ENV_ROOT/bin:$PATH"
Since our goal is to install gpu enabled tensorflow, it is a good idea to install cuda libraries before installing tensorflow.
(python3.8.5) knayem@eagles:~$ conda install https://repo.anaconda.com/pkgs/main/linux-64/cudatoolkit-10.1.243-h6bb024c_0.conda
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(python3.8.5) knayem@eagles:~$ conda install https://repo.anaconda.com/pkgs/main/linux-64/cudnn-7.6.5-cuda10.1_0.conda
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(python3.8.5) knayem@eagles:~$ conda install https://repo.anaconda.com/pkgs/main/linux-64/cupti-10.1.168-0.conda
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Install gpu version of tensorflow (version 2.3.0)using pip.
(python3.8.5) knayem@eagles:~$ pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.3.0-cp38-cp38-manylinux2010_x86_64.whl
You check if tensorflow is installed correctly in Jupyter notebook.
import os
import tensorflow as tf
from tensorflow.compat.v1.app import flags
from tensorboard.plugins.hparams import api as hp
import numpy as np
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("GPU is available" if tf.config.list_physical_devices("GPU") else "NOT AVAILABLE")
>>
Version: 2.3.0
Eager mode: True
GPU is available
Reference blogs,
[1] How to add your Conda environment to your jupyter notebook in just 4 steps, https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084
[2] Manage Conda environments, https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html