By Anonymous |
  

HPC Jupyter Kernels

To create a custom Jupyter kernel from jupyter.sdcc.bnl.gov for the HPC, You need  terminal shell access. You can  use ssh login to ic2submit01/02 via ssh gateway. Or just start a terminal from Jupyter session. 

The following command will create a  Jupyter kernel which will be based on any python environment  your  terminal session is in, whether it's some base python distribution environment or an activated python virtual env.    

python -m ipykernel install --user --name="your_kernel_name" --display-name="display-name"

Then in a short while, your Jupyter session will be able to see the new kernel available.

We recommend use "conda" to create python virtual env. 

 Example of  create python virtual env  with conda for python3.12  and some packages of some specific version:


conda create -n my-env python=3.12 pip ipykernel package1 package2=some-version ...
source activate my-env 
# or "conda activate my-env"
conda install additional_package1 additional_package2
pip install packages_not_available_in_conda

 If you want , you can create a Jupyter kernel of this env to be used from  Jupyter.sdcc.bnl.gov  
 

python -m ipykernel install --user --name "my-kernel-name" --display-name "display-name-on-jupyter"

After finish job , you might want deactivate the env so you may use base python environment or activate  a different virtualenv  for a different project which need different sets and versions of packages

conda deactivate

If  you do not want use "conda" , or the system you land on does not have "conda" . It is suggested to also create python virtual environments for different projects unless you have only one project which you can use following to install additional package to your home directory area.

 pip install --user your_additional_packages

To create python virtual env, activate/deactivate it , and install package in virtual env please follow this link https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/

Again when you are in an activated  python virtual env , make your you have  ipykernel package installed and use this command to create Jupyter kernel

python -m ipykernel install --user --name="your_kernel_name" --display-name="display-name"