Select Git revision
instructions_linux_weai.tex

Christof Kaufmann authored
instructions_linux_weai.tex 8.44 KiB
\RequirePackage{luatex85}
\documentclass[12pt]{scrartcl}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{listings}
\lstset{basicstyle=\ttfamily,
escapeinside={\#*}{*}, % escape to LaTeX
columns=flexible, % allow copying
keepspaces=true,
}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\newcommand*\keystroke[1]{%
\begin{tikzpicture}[baseline=(key.base), very thin, line cap=round, black, rounded corners=0pt]%
\node [draw, fill=white, fill opacity=1, rectangle, rounded corners=2pt, inner sep=1pt, minimum size=0.8em, font=\scriptsize\sffamily] (key) {#1};
\begin{scope}[on background layer]
\draw [rounded corners=1pt, fill=white] ($ (key.north west) + (-2pt, 2pt) $) rectangle ($ (key.south east) + (2pt, -2pt) $);
\fill [gray!60] ($ (key.south west) + (2pt, 0.1pt) $) -- ($ (key.south west) + (-1pt, -2pt) $)
-- ($ (key.south east) + (1pt, -2pt) $) -- ($ (key.south east) + (-2pt, 0.1pt) $) -- cycle;
\fill [gray!60] ($ (key.south east) + (-0.1pt, 2pt) $) -- ($ (key.south east) + (2pt, -1pt) $)
-- ($ (key.north east) + (2pt, 1pt) $) -- ($ (key.north east) + (-0.1pt, -2pt) $) -- cycle;
\end{scope}
\draw ($ (key.north west) + (0.1pt, -2pt) $) -- ($ (key.north west) + (-2pt, 1pt) $);
\draw ($ (key.north west) + (2pt, -0.1pt) $) -- ($ (key.north west) + (-1pt, 2pt) $);
\draw ($ (key.north east) + (-0.1pt, -2pt) $) -- ($ (key.north east) + (2pt, 1pt) $);
\draw ($ (key.north east) + (-2pt, -0.1pt) $) -- ($ (key.north east) + (1pt, 2pt) $);
\draw ($ (key.south west) + (0.1pt, 2pt) $) -- ($ (key.south west) + (-2pt, -1pt) $);
\draw ($ (key.south west) + (2pt, 0.1pt) $) -- ($ (key.south west) + (-1pt, -2pt) $);
\draw ($ (key.south east) + (-0.1pt, 2pt) $) -- ($ (key.south east) + (2pt, -1pt) $);
\draw ($ (key.south east) + (-2pt, 0.1pt) $) -- ($ (key.south east) + (1pt, -2pt) $);
\end{tikzpicture}%
}
\newcommand{\keyenter}{\keystroke{Enter\,\tikz [baseline=-2mm, rounded corners=0pt] \draw [semithick, -{Triangle[length=1mm, width=1mm]}] (0, 0) -- ++(down:1mm) -- ++(left:2mm);}}
\usepackage[colorlinks=true,urlcolor=blue,unicode=true,pdfusetitle]{hyperref}
\usepackage[color=blue, author={Christof Kaufmann}]{attachfile2} % load after hyperref to avoid option clash from unicode=true
\title{Installation of Python via Miniforge for Linux}
\date{October 2024}
\author{Christof Kaufmann}
% one infinite page, https://tex.stackexchange.com/a/19241/115883
\usepackage[paperheight=\maxdimen]{geometry}
\usepackage[active,tightpage]{preview}
\renewcommand{\PreviewBorder}{1ex}
% preserve parindent, https://tex.stackexchange.com/a/98214
\usepackage{etoolbox}
\edef\keptparindent{\the\parindent}
\patchcmd{\preview}
{\ignorespaces} %%% \preview ends with \ignorespaces
{\parindent\keptparindent\ignorespaces}
{}{}
\begin{document}
\begin{preview}
\vspace*{-3em}
\maketitle
% \begin{abstract}
% In dieser Installationsanleitung wird die Installation von Python mit TensorFlow, Scikit-Learn, OpenAI Gym und weiteren Paketen mit Conda gezeigt. Weiterhin wird die Installation von den Python-IDEs Spyder und Visual Studio Code gezeigt. Als Linux-Distribution wird Ubuntu angenommen. Falls Sie eine andere Distribution benutzen, müssten Sie die Befehle soweit wie möglich anpassen.
% \end{abstract}
\section{Miniforge}
First, we install \textit{Miniforge}. It is a package manager for conda packages and by default set up to use the \texttt{conda-forge} repository. Download the installation script:
\begin{lstlisting}[gobble=2, basicstyle=\ttfamily\scriptsize]
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
\end{lstlisting}
Execute the script using bash:
\begin{lstlisting}[gobble=2]
bash Miniforge3-Linux-x86_64.sh
\end{lstlisting}
Confirm that you will review the license with \keyenter, then scroll down using \keystroke{~~~~SPACE~~~~} and finally confirm it by typing \texttt{yes} and pressing \keyenter:
\begin{lstlisting}[gobble=2, basicstyle=\ttfamily\color{gray}]
Do you accept the license terms? [yes|no]
[no] >>> #*\color{black}yes*
\end{lstlisting}
You can leave the default installation path \lstinline|/home/<user>/miniforge| or, to have the home folder more tidy, use \lstinline|/home/<user>/.local/opt/miniforge|, e.\,g.\ for the user \textit{john}:
\begin{lstlisting}[gobble=2, basicstyle=\ttfamily\color{gray}]
Miniforge will now be installed into this location:
/home/john/miniforge
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/john/miniforge] >>> #*\color{black}/home/john/.local/opt/miniforge*
\end{lstlisting}
At the end of the installation you can choose to activate the default environment automatically
Nach der Installation können Sie auswählen, dass die Conda-Umgebung automatisch aktiviert werden soll:
\begin{lstlisting}[gobble=2, basicstyle=\ttfamily\color{gray}]
Do you wish the installer to initialize Miniforge
by running conda init? [yes|no]
[no] >>> #*\color{black}yes*
\end{lstlisting}
Now \lstinline|~/.bashrc| has been modified. For changes to take effect, close and re-open your current shell. In the new shell the \texttt{base} environment should be activated, which looks like this:
\begin{lstlisting}[gobble=2]
#*\color{gray}(base) \color{green!80!black}john \color{gray}→ \color{blue!90!black!70}\textasciitilde\ \color{gray}\$*
\end{lstlisting}
Now we are ready to install the packages we need.
\section{Packages}
Let's create a new environment called \textit{weai} and add the packages we need to it.
\textit{For GPU support replace \lstinline|'tensorflow<2.16'| by \lstinline|'tensorflow-gpu=2.10'| in the command below. This requires a recent propriatary NVIDIA driver installed via \lstinline|apt|, e.\,g.\ for Ubuntu \lstinline|nvidia-driver-510| or similar should be enough. For Debian \lstinline|nvidia-driver| might work (requires \lstinline|contrib| and \lstinline|non-free| in \lstinline|sources.list|).}
\begin{lstlisting}[gobble=2]
mamba create -n weai python=3.10 'tensorflow<2.16' spyder jupyter \
matplotlib seaborn tqdm mypy scikit-learn \
pandas openpyxl odfpy pyarrow notebook \
optuna plotly ipympl pip
\end{lstlisting}
You will get a list of packages and can confirm with \keyenter. Installation takes a while. Let's change into the \textit{weai} environment and start spyder
\begin{lstlisting}[gobble=2]
conda activate weai
spyder &
\end{lstlisting}
Alternatively, you can use the desktop file (\textattachfile{attachments/Spyder-weai.desktop}{attachment}|\href{https://gitlab.cvh-server.de/ckaufmann/install-python-tensorflow-gym/-/raw/master/attachments/Spyder-weai.desktop?inline=false}{web}) to start it by double-clicking. If necessary, remove the file extension \texttt{.download} so that the file extension is \texttt{.desktop}. Fix the path to the icon (example username is \texttt{john}) and make the file executable. Then copy it to your desktop folder (usually \lstinline|~/Desktop/|). If you want to see Spyder in the start menu in addition to the desktop, copy the file to \lstinline|~/.local/share/applications/|.
The Spyder window opens now. Open the test script \texttt{mnistKeras.py} (\textattachfile{attachments/mnistKeras.py}{attachment}|\href{https://gitlab.cvh-server.de/ckaufmann/install-python-tensorflow-gym/-/raw/master/attachments/mnistKeras.py?inline=false}{web}) and run it by pressing \keystroke{F5} or clicking on the green play button or by using the menu \textit{Run} $\rightarrow$ \textit{Run}.
\vspace{-1ex}
\noindent
\includegraphics[width=\linewidth]{images/spyder-linux}
\vspace{-1.5em} % due to some transparent border in the image
\noindent
The test script will output the TensorFlow version, e.\,g.:
\begin{lstlisting}
=========================
TensorFlow Version 2.10.0
=========================
\end{lstlisting}
Then TensorFlow will download the required data set once and train a neural network. The progress will be printed in the console. Finally the accuracy on the test set will be shown and some sample images will be plotted in the \textit{Plots} pane. This means Python and TensorFlow have been installed successfully.
\end{preview}
\end{document}
% \begin{verbbox}
% conda install -c anaconda tensorflow mypy pystan swig geopandas descartes tqdm ffmpeg
% \end{verbbox}
% \resizebox{\linewidth}{!}{\theverbbox}