"<img src=\"https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_pip_install_run_notebook.png\" alt=\"WARNING: could not get image from server.\" style=\"width:800px\">\n",
"\n",
"and test the installed versions via the `Version()` function in `libitmal`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from libitmal import versions\n",
"versions.Versions()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"I got the output, with a `keras` and `tensorflow` version at 2.8,0 (instead of 2.6.0 from a `conda` install): \n",
"\n",
"NOTE: this pip install needs testing and verification --- please report if it does not work on your PC!"
"```\n",
"Python version: 3.9.7.\n",
"Scikit-learn version: 0.24.2.\n",
"Keras version: 2.8.0\n",
"Tensorflow version: 2.8.0\n",
"Tensorflow.keras version: 2.8.0\n",
"OK\n",
"```\n",
"\n",
"NOTE: this pip install needs testing and verification --- please report if it does not work on your PC! "
]
},
{
...
...
@@ -172,7 +199,7 @@
"The BAT-file should contain the followin text lines, and you can place this in an icon in the taskbar allowing for easy launch of future notebooks.\n",
"REM note book start in this directory, you may change it:\n",
"cd \\\n",
"\n",
"jupyter-notebook\n",
"jupyter-notebook\n",
"\n",
"echo DONE\n",
"```"
...
...
%% Cell type:markdown id: tags:
# ITMAL Demo
## Installing Keras and Tensorflow for Anaconda 2021.11
REVISIONS| |
---------| |
2018-03-25| CEF, initial.
2020-03-05| CEF, F20 ITMAL update.
2020-03-06| CEF, investigated Anaconda 2019.10 on Windows and updated GPU server notes.
2021-10-12| CEF, updated for ITMAL E21.
2022-03-23| CEF, updated for SWMAL F22, rewrote install method for Keras via environments.
2022-03-25| CEF, elaboreated on conda and pip, and added pip install and screenshots.
### About Anaconda Package Managers
Anaconda comes with two different package managers: `conda` and `pip`
*`conda` is the prefered package manager, that will check new package installation for compability with existing packages. While this pre-compability-check is nice in theory, it often turns out, that it becomes impossible to install a given package due to incompabilities with one or more other packages. Even more annoing, the simple install of a package may take hours to complete.
*`pip` is a simpler package mangager, that comes with most Python distributions. It does none of the compability-checks when installing; it just installs whatever you ask it to (and incompabilites may then creep in in the run-time enviroment).
Normally you would try to install whatever you need via `conda` and when it breaks down due to to many broken dependencies (trying with 'flexible solve' etc. for hours), you just continue with `pip`.
If you just want a quick(-and-dirty?) install of `keras` and `tensorflow` goto the "Install via PIP" cell, otherwise try the "Install via CONDA"..
%% Cell type:markdown id: tags:
## Installing via PIP
If `conda` fails, or you just want to proceede quickly, then install everything in the base environment via pip
```bash
> pip install keras tensorflow
```
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_pip_install_tensorflow.png"alt="WARNING: could not get image from server."style="width:800px">
and then just launch the jupyter-notebook in the default (base) environment.
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_pip_install_run_notebook.png"alt="WARNING: could not get image from server."style="width:800px">
and test the installed versions via the `Version()` function in `libitmal`
%% Cell type:code id: tags:
``` python
fromlibitmalimportversions
versions.Versions()
```
%% Cell type:markdown id: tags:
I got the output, with a `keras` and `tensorflow` version at 2.8,0 (instead of 2.6.0 from a `conda` install):
```
Python version: 3.9.7.
Scikit-learn version: 0.24.2.
Keras version: 2.8.0
Tensorflow version: 2.8.0
Tensorflow.keras version: 2.8.0
OK
```
NOTE: this pip install needs testing and verification --- please report if it does not work on your PC!
%% Cell type:markdown id: tags:
## installing via CONDA
Keras will not install under Anaconda version 2021.11. It ends up in a endless package-conflict, when installing under `conda`.
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_conda_install_keras_tensorflow_conflicts.png"alt="WARNING: could not get image from server."style="width:800px">
(This is a new finding for the particular version 2021.11, and previous version did not have this tensorflow install problem, but typically only a Keras install problem).
The root-cause of the problem must be missing check when packageing the Anaconda, failing to find the set of conflicts we see, when installing `tensorflow` in the set of default installe packages that comes with the Anaconda distribution.
#### 1) Prepare and Ceate a new Environment
So, one solution is to create a new conda environment, and from this install `scikit-learn` and `tensorflow` and `keras`,
Later we need a package called `nb_conda_kernels`, let us install this before we create and activate the new enviroment
```bash
(base)> conda install nb_conda_kernels
```
Now, let us call our enviroment `swmal` and create it by running
```bash
(base)> conda create --name swmal
```
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_conda_install_keras_tensorflow_create_env.png"alt="WARNING: could not get image from server."style="width:800px">
(your install drive is probally `C:\`, I used `Z:\` due to my virtual machine environment.)
Activate the newly created enviroment it via
```bash
(base)> conda activate swmal
```
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_conda_install_keras_tensorflow_activate_env.png"alt="WARNING: could not get image from server."style="width:600px">
#### 2) Install Needed Packages
Now we got a clean state enviroment and we need to install the packages needed for `scikit-learn` and `tensorflow`, but this is as easy as
```bash
(swmal)> conda install scikit-learn tensorflow keras nb_conda_kernels
```
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_conda_install_keras_tensorflow_installing.png"alt="WARNING: could not get image from server."style="width:800px">
Notice that the package `nb_conda_kernels` also needs to be installed in this new enviroment, and it actually also installes the jupyter notebook packages.
#### 3) Launching Jupyter-Notebooks in the new Enviroment
There are two `keras` interfaces, the stand-alone `keras`, and then a similar interface already build into `tensorflow.keras`. You could use both, but direct access via the stand-alone inteface may be the most obvious.
```bash
(swmal)> jupyter-notebook
```
<imgsrc="https://itundervisning.ase.au.dk/SWMAL/L06/Figs/Screenshot_conda_install_keras_tensorflow_notebook.png"alt="WARNING: could not get image from server."style="width:800px">
For some reason there now is a missing function in the `pythoncom39.dll` reported via the "Entry Point not Found" dialog,, but just ignore this warning for now (or find a fix and share it).
#### 4) Testing the New Enviroment Setup
Lets see the version installed in the new `swmal` environment via the `Versions()` function found in the `itmallib`
%% Cell type:code id: tags:
``` python
fromlibitmalimportversions
versions.Versions()
```
%% Output
Python version: 3.9.7.
Scikit-learn version: 1.0.2.
Keras version: 2.6.0
Tensorflow version: 2.6.0
Tensorflow.keras version: 2.6.0
Opencv2 version: 4.5.5
%% Cell type:markdown id: tags:
The `Versions()` function should print whatever version you installed, or produce a warning, if the package is not installed at all.
For my current Windows/Anaconda setup I got the versions, Yours may differ slightly
```
Python version: 3.9.7.
Scikit-learn version: 1.0.2.
Keras version: 2.6.0
Tensorflow version: 2.6.0
Tensorflow.keras version: 2.6.0
```
#### 5) Wrapping It All Up in a BAT File
To make development easy, a BAT (Windows batch or script file) shold be created. This should ease the launch of Jupyter-Notebooks and the BAT file could be put in a icon placed on the taskbar or similar.
The BAT-file should contain the followin text lines, and you can place this in an icon in the taskbar allowing for easy launch of future notebooks.