Jupyter: Difference between revisions

From FlowerHouseWiki
Line 180: Line 180:


==== Tensorflow ====
==== Tensorflow ====
<p>Install Tensorflow with pip</p>
<p>Activate environment</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
pip3 install --upgrade tensorflow requests
source Keras/bin/activate
</syntaxhighlight>
</syntaxhighlight>


<p>Check if installation works</p>
<p>Install tensorflow</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
pip install tensorflow
</syntaxhighlight>
</syntaxhighlight>


<p>As server has no GPU, disable it with environment variable:</p>
<p>Verify tensorflow installation:</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
nano /etc/environment
python3 -m pip show tensorflow
</syntaxhighlight>
</syntaxhighlight>


<p>Add following line:</p>
<p>Update tensorflow with</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
CUDA_VISIBLE_DEVICES="-1"
pip install --upgrade tensorflow
pip install --upgrade keras
</syntaxhighlight>
</syntaxhighlight>


==== Keras ====
==== Keras ====
<p>Activate environment</p>
<syntaxhighlight lang="console">
source Keras/bin/activate
</syntaxhighlight>
<p>Install Keras</p>
<p>Install Keras</p>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
apt install python3-keras
pip install keras
</syntaxhighlight>
 
<p>Verify Keras installation:</p>
<syntaxhighlight lang="console">
pip show keras
</syntaxhighlight>
</syntaxhighlight>



Revision as of 20:09, 11 March 2022

Juypter.png

Network


IP: 192.168.88.18
MAC: 6A:1B:42:9D:D6:4B
Domain: jupyter.flowerhouse.at

System


OS: Debian Bullseye
RAM: 4096MB
Cores: 4
Privileged: No

The Jupyter-LXC is reachable under 192.168.88.18 which is located in the ServerVLAN.

The subdomain is jupyter.flowerhouse.at which is handled by the ReverseProxy.

Basic Setup

Installation

Install required packages

apt install python3-pip npm

Install JupyterHub, responsible for managing multiple users

python3 -m pip install jupyterhub

Install Proxy needed by JupyterHub

npm install -g configurable-http-proxy

Install webinterface and notebook

python3 -m pip install jupyterlab notebook

Configuration

Create config file

Create folder for config

mkdir /etc/jupyterhub

Generate config file

jupyterhub --generate-config -f /etc/jupyterhub/jupyterhub_config.py

Create systemd service

Create service file

nano /etc/systemd/system/jupyter.service

Add this content to file

[Unit]
Description=Jupyterhub
After=syslog.target network.target

[Service]
User=root
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/anaconda3/bin"
ExecStart=jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

[Install]
WantedBy=multi-user.target

Reload systemd

systemctl daemon-reload

Start Jupyter and check if its running

systemctl start jupyter
systemctl status jupyter

Start Jupyter at boot

systemctl enable jupyter

Create/Add user

Create new user

adduser [username]

Extensions/Kernels

SageMath

Install SageMath Kernel

apt install sagemath

C++

Install Miniconda

Download install script

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Run install script and reboot

bash Miniconda3-latest-Linux-x86_64.sh

Update conda

conda update --all

Install Xeus-Cling

Install xeus-cling

conda install xeus-cling -c conda-forge

Add kernel

Add C++11 kernel

jupyter kernelspec install ~/miniconda3/share/jupyter/kernels/xcpp11

Add C++14 kernel

jupyter kernelspec install ~/miniconda3/share/jupyter/kernels/xcpp14

Add C++17 kernel

jupyter kernelspec install ~/miniconda3/share/jupyter/kernels/xcpp17

Restart Jupyter

systemctl restart jupyter

AI

Create environment

Install venv

apt install python3-venv

Create folder where environment should be located at

mkdir /home/venv
cd /home/venv

Create Keras-Environment

python3 -m venv Keras

Activate environment

source Keras/bin/activate

Install iPython Kernel

pip install ipykernel

Add virtual environment to jupyter

python -m ipykernel install --name=Keras

Deactivate with:

deactivate

Tensorflow

Activate environment

source Keras/bin/activate

Install tensorflow

pip install tensorflow

Verify tensorflow installation:

python3 -m pip show tensorflow

Update tensorflow with

pip install --upgrade tensorflow
pip install --upgrade keras

Keras

Activate environment

source Keras/bin/activate

Install Keras

pip install keras

Verify Keras installation:

pip show keras

Sources