Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel1
outlinefalse
stylenone
typelist
printabletrue

...

General Process

Info

The general process involves updating the conda environment to include kernel related packages, and then configuring the kernel spec to allow it to be picked up by the Jupyter service.

  1. Activate you Python Conda Environment.

  2. Conda install the ipykernel package.

  3. Deactivate your Conda environment.

  4. Copy the created kernelspec into your home .local/share/jupyter/kernels/ folder.

  5. Update the kernel.json.

Note

The process creates a kernel for an individual user from the previously created shared Conda environment.

Each individual from the shared space will need to follow this process to create their own kernel.

Note

If anyone updated the packages within this shared Conda environment, then the update will effect everyone. Be warned.

...

Install the ipykernel package

Code Block
[salexan5@mblog1 ~]$ module load miniconda3/24.3.0
[salexan5@mblog1 ~]$ conda activate /cluster/medbow/project/arcc/software/tensorflow/2.16
(/cluster/medbow/project/arcc/software/tensorflow/2.16) [salexan5@mblog1 ~]$ export PYTHONUSERBASE=$CONDA_PREFIX
(/cluster/medbow/project/arcc/software/tensorflow/2.16) [salexan5@mblog1 ~]$ conda install ipykernel
...
(/cluster/medbow/project/arcc/software/tensorflow/2.16) [salexan5@mblog1 ~]$ conda deactivate

...

Created kernel related folder

Info

Installing the ipykernel package will create a kernel spec related folder that we can use.

This can be found under the Conda environment location, under: share/jupyter/kernels/ named python3

Code Block
[salexan5@mblog1 ~]$ ls /project/arcc/software/tensorflow/2.16/share/jupyter/kernels/python3/

[salexan5@mblog1 ~]$ cd /project/arcc/software/tensorflow/2.16
[salexan5@mblog1 2.16]$ cd share/jupyter/kernels/
[salexan5@mblog1 kernels]$ ls
python3

[salexan5@mblog1 kernels]$ ls python3
kernel.json  logo-32x32.png  logo-64x64.png  logo-svg.svg
Info

Rename the folder to something more appropriate:

Code Block
[salexan5@mblog1 kernels]$ mv python3 TF2.16

...

Configure Your Jupyter Environment

Note

If you haven’t used the Jupyter service, then you might not have, and thus will need to create the following folders:

.local/share/jupyter/kernels/

Info

Copy the created TF2.16 folder into your home:

Code Block
[salexan5@mblog1 kernels]$ cp -r TF2.16/ ~/.local/share/jupyter/kernels/
Info

Update the kernel.json file to:

  • give this kernel a unique display name.

Code Block
[salexan5@mblog1 kernels]$ ~/.local/share/jupyter/kernels/TF2.16/
[salexan5@mblog1 tf2.16]$ cat kernel.json
{
 "argv": [
  "/cluster/medbow/project/arcc/software/tensorflow/2.16/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "TF2.16 (local)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

...

Start Jupyter

Info

From OnDemand start a Jupyter session.

Notice how the newly configured kernel is now available.

...

Within a Notebook

Within a cell try:

Code Block
import tensorflow as tf; 
print("TensorFlow Version: " + str( tf.__version__))
Code Block
TensorFlow Version: 2.16.1

...

...