PrimeHub
  • Introduction
  • Installation
  • Tiers and Licenses
  • End-to-End Tutorial
    • 1 - MLOps Introduction and Scoping the Project
    • 2 - Train and Manage the Model
    • 3 - Compare, Register and Deploy the Model
    • 4 - Build the Web Application
    • 5 - Summary
  • User Guide
    • User Portal
    • Notebook
      • Notebook Tips
      • Advanced Settings
      • PrimeHub Notebook Extension
      • Submit Notebook as Job
    • Jobs
      • Job Artifacts
      • Tutorial
        • (Part1) MNIST classifier training
        • (Part2) MNIST classifier training
        • (Advanced) Use Job Submission to Tune Hyperparameters
        • (Advanced) Model Serving by Seldon
        • Job Artifacts Simple Usecase
    • Models
      • Manage and Deploy Model
      • Model Management Configuration
    • Deployments
      • Pre-packaged servers
        • TensorFlow server
        • PyTorch server
        • SKLearn server
        • Customize Pre-packaged Server
        • Run Pre-packaged Server Locally
      • Package from Language Wrapper
        • Model Image for Python
        • Model Image for R
        • Reusable Base Image
      • Prediction APIs
      • Model URI
      • Tutorial
        • Model by Pre-packaged Server
        • Model by Pre-packaged Server (PHFS)
        • Model by Image built from Language Wrapper
    • Shared Files
    • Datasets
    • Apps
      • Label Studio
      • MATLAB
      • MLflow
      • Streamlit
      • Tutorial
        • Create Your Own App
        • Create an MLflow server
        • Label Dataset by Label Studio
        • Code Server
    • Group Admin
      • Images
      • Settings
    • Generate an PrimeHub API Token
    • Python SDK
    • SSH Server Feature
      • VSCode SSH Notebook Remotely
      • Generate SSH Key Pair
      • Permission Denied
      • Connection Refused
    • Advanced Tutorial
      • Labeling the data
      • Notebook as a Job
      • Custom build the Seldon server
      • PrimeHub SDK/CLI Tools
  • Administrator Guide
    • Admin Portal
      • Create User
      • Create Group
      • Assign Group Admin
      • Create/Plan Instance Type
      • Add InfuseAI Image
      • Add Image
      • Build Image
      • Gitsync Secret for GitHub
      • Pull Secret for GitLab
    • System Settings
    • User Management
    • Group Management
    • Instance Type Management
      • NodeSelector
      • Toleration
    • Image Management
      • Custom Image Guideline
    • Volume Management
      • Upload Server
    • Secret Management
    • App Settings
    • Notebooks Admin
    • Usage Reports
  • Reference
    • Jupyter Images
      • repo2docker image
      • RStudio image
    • InfuseAI Images List
    • Roadmap
  • Developer Guide
    • GitHub
    • Design
      • PrimeHub File System (PHFS)
      • PrimeHub Store
      • Log Persistence
      • PrimeHub Apps
      • Admission
      • Notebook with kernel process
      • JupyterHub
      • Image Builder
      • Volume Upload
      • Job Scheduler
      • Job Submission
      • Job Monitoring
      • Install Helper
      • User Portal
      • Meta Chart
      • PrimeHub Usage
      • Job Artifact
      • PrimeHub Apps
    • Concept
      • Architecture
      • Data Model
      • CRDs
      • GraphQL
      • Persistence Storages
      • Persistence
      • Resources Quota
      • Privilege
    • Configuration
      • How to configure PrimeHub
      • Multiple Jupyter Notebook Kernels
      • Configure SSH Server
      • Configure Job Submission
      • Configure Custom Image Build
      • Configure Model Deployment
      • Setup Self-Signed Certificate for PrimeHub
      • Chart Configuration
      • Configure PrimeHub Store
    • Environment Variables
Powered by GitBook
On this page
  • Goal
  • What is virtual environment
  • Use Conda
  • Use virtualenv(venv)
  • Install the specific library version in the virtual environment
  1. Developer Guide
  2. Configuration

Multiple Jupyter Notebook Kernels

PreviousHow to configure PrimeHubNextConfigure SSH Server

Last updated 2 years ago

Goal

Use Coda or venv to manage packages environment with specific Python versions

What is virtual environment

A cooperatively isolated runtime environment that allows Python users and applications to install and upgrade Python distribution packages without interfering with the behaviour of other Python applications running on the same system.

We can choose the Conda way or the standard Python way to achieve it.

Use Conda

Ensure Conda is installed

conda –V

Update Conda

conda update conda

Create a new environment with desired Python version

conda create --name myenv python=3.6.8

Activate the new environment

source activate myenv

In the new environment, install ipykernel

conda install ipykernel

Register a new ipykernel

python -m ipykernel install --user --name myenv

Launch a new Notebook using the myenv kernel

In the notebook script !python -V may return the incorrect version. The system level Python may be returned, and not the version in use in the current kernel environment.


Use virtualenv(venv)

Open Terminal and run, it will create a venv corresponding to the specific_python_version

/path/to/specific_python_version -m venv myenv_py_version

and activate/switch to the venv:

source myenv_py_version/bin/activate

then install iPython kernel package and register a new ipykernel in the current venv:

pip install ipykernel
python -m ipykernel install --user --name=myenv_py_version --display-name "Python <specific_version>"

list available kernel spec for the verification

jupyter kernelspec list

# e.g. output
$ Available kernels:
  myenv_py_version      /home/jovyan/.local/share/jupyter/kernels/myenv_py_version
  python3    /home/jovyan/.local/share/jupyter/kernels/python3

Activate virtualenv

source myenv_py_version/bin/activate

Launch Notebook with specific kernel/venv

Switch Notebook Kernel anytime

Verify Python version in Notebook

# run the code in a cell
import sys
sys.version_info

# e.g. output
# sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)

Install the specific library version in the virtual environment

Activate the specific virtual environment.

The Conda way

source activate myenv

or the standard Python way

source myenv_py_version/bin/activate

Then install the specific library version in this virtual environment. The dependency in this environment is independent from others.

pip install tensorflow==2.1

The library/package version varies with different kernels(virtual environment)

Reference: Virtual Environments and Packages ⇗