"2020-0306| CEF, investigated Anaconda 2019.10 on Windows and updated GPU server notes.\n",
"2021-1012| CEF, updated for ITMAL E21.\n",
"\n",
"### Install Keras via Anaconda Prompt\n",
"\n",
"1: Launch the __anaconda prompt__ console (CMD), via the Start menu\n",
"\n",
"<img src=\"https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt.png\" alt=\"WARNING: you need to be logged into Blackboard to view images\" style=\"width:200px\">\n",
...
...
@@ -74,8 +76,8 @@
"Initial:\n",
"\n",
"```python\n",
"Python version: 3.7.4.\n",
"Scikit-learn version: 0.21.3.\n",
"Python version: 3.8.5.\n",
"Scikit-learn version: 0.23.2.\n",
"WARN: could not find keras!\n",
"WARN: could not find tensorflow!\n",
"WARN: could not find tensorflow.keras!\n",
...
...
@@ -84,29 +86,36 @@
"and after installing Keras (and hence implicitly TensorFlow) on Windows\n",
"\n",
"```python\n",
"Python version: 3.7.4.\n",
"Scikit-learn version: 0.21.3.\n",
" Using TensorFlow backend.\n",
"Keras version: 2.3.1\n",
"Tensorflow version: 2.1.0\n",
"Tensorflow.keras version: 2.2.4-tf\n",
"```"
"Python version: 3.8.5.\n",
"Scikit-learn version: 0.23.2.\n",
"Keras version: 2.4.3\n",
"Tensorflow version: 2.2.0\n",
"Tensorflow.keras version: 2.3.0-tf\n",
"Opencv2 version: 4.5.1\n",
"```\n",
"\n",
"### Install Keras via Anaconda GUI\n",
"\n",
"If you dislike the Anacoda prompt and prefer a GUI, then launch the Anaconda Navigator, goto the Environment tab and enter 'keras' in the search prompt\n",
"\n",
"<img src=\"https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt_install_3.png\" alt=\"WARNING: you need to be logged into Blackboard to view images\" style=\"width:700px\">\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Python version: 3.7.4.\n",
"Scikit-learn version: 0.21.3.\n",
"Keras version: 2.2.4\n",
"Tensorflow version: 2.0.0\n",
"Tensorflow.keras version: 2.2.4-tf\n"
"Python version: 3.8.5.\n",
"Scikit-learn version: 0.23.2.\n",
"Keras version: 2.4.3\n",
"Tensorflow version: 2.2.0\n",
"Tensorflow.keras version: 2.3.0-tf\n",
"Opencv2 version: 4.5.1\n"
]
}
],
...
...
%% Cell type:markdown id: tags:
# ITMAL Demo
## Installing Keras
REVISIONS| |
---------| |
2018-0325| CEF, initial.
2020-0305| CEF, F20 ITMAL update.
2020-0306| CEF, investigated Anaconda 2019.10 on Windows and updated GPU server notes.
2021-1012| CEF, updated for ITMAL E21.
### Install Keras via Anaconda Prompt
1: Launch the __anaconda prompt__ console (CMD), via the Start menu
<imgsrc="https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt.png"alt="WARNING: you need to be logged into Blackboard to view images"style="width:200px">
2: list installed packages via
```bash
> conda list
```
in the anaconda console.
<imgsrc="https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt_install_0.png"alt="WARNING: you need to be logged into Blackboard to view images"style="width:700px">
3: install keras via
```bash
> conda install keras
```
and WAIT for 1 to 30 min before the spin-progress bar finish (a problem makes `conda` extreme slow in the latest two releases of anaconda!).
<imgsrc="https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt_install_1.png"alt="WARNING: you need to be logged into Blackboard to view images"style="width:700px">
After install, you can see the Keras and Tensorflow version via ```conda list keras``` and ```conda list tensorflow```, but notice that you might also want to install the GPU version of Tensoflow, if our PC has a suitable GPU (need CUDA support). Below I did not install the GPU version seen by the call ```conda list tensorflow-gpu```
<imgsrc="https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt_install_2.png"alt="WARNING: you need to be logged into Blackboard to view images"style="width:700px">
4: if it downgrades your Scikit-learn (use version function in the cell below), then try removing keras and/or tensorflow and reinstall
```bash
> conda remove keras tensorflow
```
```bash
> conda install keras tensorflow
```
or perhaps try installing from conda-forge
```
conda install -c conda-forge tensorflow keras
```
5: if everything fails: use the ASE GPU cluster or use keras in TensorFlow ala
```python
importtensorflowastf
mnist=tf.keras.datasets.mnist.load_data()
```
My local installation has the following version setup (yours may vary)
Initial:
```python
Pythonversion:3.7.4.
Scikit-learnversion:0.21.3.
Pythonversion:3.8.5.
Scikit-learnversion:0.23.2.
WARN:couldnotfindkeras!
WARN:couldnotfindtensorflow!
WARN:couldnotfindtensorflow.keras!
```
and after installing Keras (and hence implicitly TensorFlow) on Windows
```python
Pythonversion:3.7.4.
Scikit-learnversion:0.21.3.
UsingTensorFlowbackend.
Kerasversion:2.3.1
Tensorflowversion:2.1.0
Tensorflow.kerasversion:2.2.4-tf
Pythonversion:3.8.5.
Scikit-learnversion:0.23.2.
Kerasversion:2.4.3
Tensorflowversion:2.2.0
Tensorflow.kerasversion:2.3.0-tf
Opencv2version:4.5.1
```
### Install Keras via Anaconda GUI
If you dislike the Anacoda prompt and prefer a GUI, then launch the Anaconda Navigator, goto the Environment tab and enter 'keras' in the search prompt
<imgsrc="https://itundervisning.ase.au.dk/GITMAL/L07/Figs/Screenshot_anaconda_prompt_install_3.png"alt="WARNING: you need to be logged into Blackboard to view images"style="width:700px">
%% Cell type:code id: tags:
``` python
# DEMO of Versions in libitmal
fromlibitmalimportversionsasitmalversions
itmalversions.Versions()
```
%%%% Output: stream
Python version: 3.7.4.
Scikit-learn version: 0.21.3.
Keras version: 2.2.4
Tensorflow version: 2.0.0
Tensorflow.keras version: 2.2.4-tf
Python version: 3.8.5.
Scikit-learn version: 0.23.2.
Keras version: 2.4.3
Tensorflow version: 2.2.0
Tensorflow.keras version: 2.3.0-tf
Opencv2 version: 4.5.1
%% Cell type:markdown id: tags:
# Using the ASE GPU Cluster
%% Cell type:markdown id: tags:
### Client GPU Support
If your own computer has a CUDA-compatible GPU you might also want to install TensorFlow for the GPU
```
conda install tensorflow-gpu
```
### Server GPU support
You also have an ITMAL group account on our GPU Cluster server at
* http://gpucluster.st.lab.au.dk/
Find login details etc. in Blackboard ("Kursusinfo | GPU Cluster"):
For all users, I've added a startup-script when you log into the GPU server. The startup-script is found in
* /home/shared/00_init.py
and among other things, add your home-folder to the PYTHON path.
When running on the GPU-server you are automatically assigned 10% of the GPU memory. This is also done via the startup-script, and you are allowed to increase you GPU memory fraction if needed by calling the Enable GPU function in ```/home/shared/00_init.py``` (or the module ```kernelfun``` in ``libitmal```) like
NOTE 1: processes using more than 50% GPU memory will automatically be killed with an interval of about 5 min, and python kernels running for more than about a week will also be terminated automatically.
NOTE 2: most Scikit-learn ML algorithms (if not all) do NOT use the GPU at all. You need to move to Tensorflow/Keras to get true GPU hardware support.
NOTE 3: notebooks will keep running on the server, even if you shut-down you web connection to it. Print output will hence be lost, but you can still start long running model training on the server, and come back later to see if its finished...(on the same Node).
NOTE 4: If you need to stop you server: use the "Control Panel (upper right) | Stop my server" to shut down all your kernels and release all memory.
%% Cell type:code id: tags:
``` python
# DEMO of set GPU memory fraction in libitmal
from libitmal import kernelfuns as itmalkernefuns
itmalkernefuns.EnableGPU()
# See kernel running, but works only if you got CUDA installed
! nvidia-smi
```
%%%% Output: stream
ERROR: something failed in EnableGPU(), Tensorflow part
/bin/sh: 1: nvidia-smi: not found
%% Cell type:markdown id: tags:
### GPU Server GIT/PYTHONPATH setup
On the GPU server You can clone the git repository inside the Jupyternotbook via