Goal: Demonstrate extending a python Python related conda environment in to Juypter kernel.
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
What is Jupyter and What is a Kernel?
Note |
---|
|
...
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. |
Activate you Python Conda Environment.
Conda install the
ipykernel
package.Deactivate your Conda environment.
Copy the created
kernelspec
into your home.local/share/jupyter/kernels/
folder.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 |
---|
[]$ module purge
[]$ module load miniconda3/24.3.0
[]$ conda activate /cluster/medbow/project/<project-name>/software/tensorflow/2.16
(/cluster/medbow/project/<project-name>/software/tensorflow/2.16) []$ export PYTHONUSERBASE=$CONDA_PREFIX
(/cluster/medbow/project/<project-name>/software/tensorflow/2.16) []$ conda install ipykernel
...
(/cluster/medbow/project/<project-name>/software/tensorflow/2.16) []$ python -m ipykernel install --user --name=TF2.16-local
(/cluster/medbow/project/<project-name>/software/tensorflow/2.16) []$ conda deactivate
[]$ |
...
The Related Kernel Details
Info |
---|
Using the |
Code Block |
---|
() (/project/<project-name>/software/tensorflow/2.16) []$ python -m ipykernel install --user --name=TF2.16-local
Installed kernelspec TF2.16-local in /cluster/medbow/home/<username>/.local/share/jupyter/kernels/tf2.16-local |
Info |
---|
Notice: This file is created in the user's |
Code Block |
---|
[]$ ls /cluster/medbow/home/<username>/.local/share/jupyter/kernels/tf2.16-local/ kernel.json logo-32x32.png logo-64x64.png logo-svg.svg []$ cat /cluster/medbow/home/<username>/.local/share/jupyter/kernels/tf2.16-local/kernel.json { "argv": [ "/project/<project-name>/software/tensorflow/2.16/bin/python", "-Xfrozen_modules=off", "-m", "ipykernel_launcher", "-f", "{connection_file}" ], "display_name": "TF2.16-local", "language": "python", "metadata": { "debugger": true } } |
Info |
---|
Suggestion: Using “ |
...
Create a Shared TensorFlow Conda Environment
...
Info |
---|
Side Note: Installing the Running |
Note |
---|
Kernel names can only contain ASCII letters and numbers and these separators: - . _ (hyphen, period, and underscore) Names can not use whitespace such as |
...
Start Jupyter
Info |
---|
From OnDemand start a Jupyter session. Notice how the newly configured kernel is now available. |
...
Within a Notebook
Within a Jupyter notebook cell try:
Code Block |
---|
import tensorflow as tf;
print("TensorFlow Version: " + str( tf.__version__)) |
Code Block |
---|
TensorFlow Version: 2.16.1 |
...
Prev | Workshop Home | Next |
Add label