[[breakout]]

This is an old revision of the document!


Breakout - GPU HPC an der Fakultät Elektrotechnik

Der Rechner breakout.hs-augsburg.de ist ein im Rechenzentrum installierter GPU Rechner für Maschinelles Lernen.

  • SuperMicro SYS-7048GR-TR
  • Mainboard Supermicro X10DRG-Q
  • 2 x Intel Xeon Broadwell E5-2690v4 (2.6 GHz, 14 Core)
  • 128 GB DDR4 RAM mit 2400 MHz
  • 2 x 480 GB SATA3 SSD Intel DC S3500
  • 1 x 400 GB PCIe NVME SSD P3500
  • Intel X540-T2 10GB Base-T Ethernet Netzwerkanschluss
  • 4 x NVIDIA Geforce GTX 1080 mit GP104 Pascal, 2560 Cores, 8 GB RAM
  • Debian Linux Jessie, NVIDIA Cuda, Torch
  • NVidia Treiber 367.48
  • Kernel 3.16
  • Cuda 8.0.44

Alle Angehörigen der Hochschule können sich mit dem Account des Rechenzentrums auf der breakout über ssh einloggen. Der Zugang über den ssh Standardport 22 ist nur innerhalb des Intranets (ggf. über vpn) erreichbar. Zusätzlich ist der Port 2222 für ssh auch von außerhalb zugänglich. Die Beschreibung geht von einem terminal unter MacOS aus. Einloggen über ssh:

MacBook: ssh -p 2222 <rzaccount>@hs-augsburg.de

Auf der breakout wird dann das Benutzerverzeichnis, das zu dem account gehört, gemountet.

X Forwarding

Einfache X Anwendungen können über X Forwarding gestartet werden. Dazu ist ein X Server auf dem Clientrechner (also dem Mac) erforderlich. Die Option “-Y” aktiviert dazu das X Forwarding der ssh shell.

MacBook: ssh -Y -p 2222 <rzaccount>@hs-augsburg.de

Dann kann man auf der breakout als X Beispielprogramm “xlogo” starten.

breakout: xlogo

VirtualGL und TurboVNC

Das X Forwarding ist jedoch mit 3D Beschleunigung und einer langsamen Internetanbindung nicht so gut geeignet. Deshalb ist auf der breakout auch TurboVNC und VirtualGL installiert. Auf der breakout ist das in der Hintergrundbeschreibung auf http://www.virtualgl.org/About/Background in Figure 5 “In-Process GLX Forking with an X Proxy” dargestellte Verfahren konfiguriert. Auf der breakout läuft dazu der Standard X Server für die 3D Beschleunigung. Vom Nutzer wird dann noch der XProxy Server “XVnc” und LXDE gestartet. Dieser vncserver ist dann wie ein “Remote Desktop”, d.h. es werden nur Bilddaten vom Server zum Client geschickt. Der vncserver stellt die vnc Daten an einem Port 5900 + n zur Verfügung. Dabei ist n die Displayvariable des aktuellen vncservers. Die breakout ist allerdings so konfiguriert, das der Port nicht von außerhalb erreichbar ist. Deshalb muss ssh mit Portforwarding gestartet werden. Welchen Port man forwarden muss, ergibt erst nach dem Start des vncservers.

Auf dem Client muss dazu ein VNC Client installiert werden. Da auf der breakout der vncserver von TurboVNC installiert ist, empfehle ich den TurboVNC Client. Siehe http://www.turbovnc.org

Zunächst vom Client (hier: MacBook) auf der breakout einloggen

MacBook: ssh -p 2222 fritz@hs-augsburg.de

Dann auf der breakout den vncserver starten. Das sieht dann so aus:

fritz@breakout:~$ vncserver

Desktop 'TurboVNC: breakout:1 (fritz)' started on display breakout:1

Starting applications specified in /home/fritz/.vnc/xstartup.turbovnc
Log file is /home/fritz/.vnc/breakout:1.log

fritz@breakout:~$ 

Hier wurde als Display “breakout:1” dynamisch ausgewählt. Deshalb muss der vnc client auf den Port 5901 zugreifen. Dieser port 5901 wird mit port forwarding von der breakout über eine ssh session auf den lokalen Rechner geleitet. Deshalb jetzt eine zweite ssh Session mit port forwarding von Port 5901.

MacBook: ssh -p 2222 -L 5901:localhost:5901 fritz@breakout.hs-augsburg.de

Damit stehen jetzt die vnc Daten auf dem Clientrechner an Port 5901 zur Verfügung. Der TurboVNC Client muss deshalb mit “localhost:5901” verbunden werden.

Auf der breakout ist NVidia Cuda installiert. Um den Cuda Compiler nutzen zu können muss in die Datei <HOME>/.profile

# Add the CUDA compiler
PATH="$PATH:/usr/local/cuda/bin"

eingetragen werden. Danach Ausloggen und wieder einloggen.

Alle debian Pakete für die Installation von Torch sind auf der breakout installiert. Torch selbst wird nicht über die Debian Paketinstallation installiert, sondern im Homeverzeichnis direkt aus git. Im Beispiel wird eine Version ausgecheckt, die funktioniert hat. Der Schritt install-deps.sh wird übersprungen, da dort mit sudo Pakete installiert werden. Diese Pakete kann man als normaler user aufgrund der sudo Rechte nicht installieren und sie sind auf der breakout auch schon installiert.

cd
git clone https://github.com/torch/distro.git ~/torch --recursive
git checkout efb9226e924d69513eea28f5f701cb5f5ca
cd torch
TORCH_LUA_VERSION=LUA52 ./install.sh
source "$HOME/torch/install/bin/torch-activate"

Now add to .profile

# NVidia cuDNN library
if [ -f "/home/fritz/cuda/cudnn/cuda/lib64/libcudnn.so.6" ]; then
  export CUDNN_PATH="/home/fritz/cuda/cudnn/cuda/lib64/libcudnn.so.6"
fi
# Torch environment settings
if [ -f "$HOME/torch/install/bin/torch-activate" ]; then
  source "$HOME/torch/install/bin/torch-activate"
fi

Als Beispiel kann man http://torch.ch/blog/2015/07/30/cifar.html ausprobieren. Dort werden 50000 Bilder aus dem CIFAR-10 Benchmark klassifiziert.

cd
git clone https://github.com/szagoruyko/cifar.torch.git
cd cifar.torch
OMP_NUM_THREADS=2 th -i provider.lua
# Opens torch shell - inside th:
provider = Provider()
provider:normalize()
torch.save('provider.t7',provider)
exit
# Now back on shell
CUDA_VISIBLE_DEVICES=0 th train.lua --model=vgg_bn_drop -s logs/vgg

The previous training uses the cuda compiled torch neural network models. NVidia provides specially crafted cuDNN models which are faster. To use these models:

CUDA_VISIBLE_DEVICES=0 th train.lua --model=vgg_bn_drop --backend=cudnn -s logs/cudnn

The network can also be trained without cuda/gpu support:

OMP_NUM_THREADS=16 th train.lua --model=vgg_bn_drop --type=float -s logs/cpu

Mit Docker können zusätzliche Softwarepakete laufen ohne die Basisinstallation zu ändern. Vorraussetzung

  • Ihr Account muss Mitglied der Gruppe “docker” sein

Testen Sie ob Sie Mitglied der Gruppe docker sind mit

groups

Wenn Sie nicht Mitglied der Gruppe docker sind, dann funktionieren die folgenden Aktionen nicht. Bitte beachten Sie, dass Aktionen unter Docker sicherheitsrelevant sind. Durch das Mounten von Verzeichnissen mit der -v Option können auch Dateien im Host verändert werden, die unter root Rechten stehen.

Einfacher Test

NVidia Digits

siehe: https://github.com/NVIDIA/nvidia-docker/wiki/DIGITS

nvidia-docker run --name digits -d -P nvidia/digits
  • Option -d will run the docker image as daemon.
  • Option -P will assign the used ports inside docker to random ports on the host.

To check which ports are assigned and which containers are running:

docker ps

In my example it looks like this:

fritz@breakout:~/docker$ docker ps
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                     NAMES
f9942fca476a        nvidia/digits       "python -m digits"   32 minutes ago      Up 3 seconds        0.0.0.0:32772->5000/tcp   digits
fritz@breakout:~/docker$ 

The section “PORTS” shows that port 5000 from the docker container is mapped to port 32772 on the host. Now you can run a web browser with “http://breakout.hs-augsburg.de:32772” and see the NVidia Digits web interface.

To stop NVidia Digits run

docker stop digits
docker rm digits

With Python 2

Tensorflow version 1.4 supports Cuda 8.0 while all following versions require Cuda 9. The supported tensorflow version on this machine is 1.4. The recommended way to install tensorflow is “virtualenv”.

https://www.tensorflow.org/versions/r1.4/install/

Change your .profile and add the following

# nvidia cuDNN library
LD_LIBRARY_PATH="/usr/local/cuda/lib64:/home/fritz/cuda/cudnn/cuda/lib64:$LD_LIBRARY_PATH"

to make the cuda and cudnn library accessible. Logout and login. Tensorflow 1.4 requires cuda 8.0 and cudnn 6.0. This machine uses python 2.7.

Install tensorflow:

virtualenv --system-site-packages ~/tensorflow
source ~/tensorflow/bin/activate
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.4.0-cp27-none-linux_x86_64.whl

Then validate that the installation worked.

With Python 3

Alternatively, you can also use Tensorflow with Python 3 on the server. Similar to the python2 version described above, only TensorFlow 1.4 is supported, but cuDNN 7.0 is used. Just add the following code to your ~/.profile

if [ -d "/fast/usr/bin" ] ; then
    PATH="/fast/usr/bin:$PATH"
fi

if [ -d "/fast/usr/local/cuda-8.0/lib64" ] ; then
    export LD_LIBRARY_PATH="/fast/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH"
fi

Once you reconnected to the server, you are ready to use python3 with TensorFlow.

I installed PyTorch via miniconda in my home directory. Anaconda/Miniconda is an installation method for python tools. The installation of miniconda is described here. I used the 64 Bit version for python 2.7. The download is here. So I did:

cd
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh
conda update conda
mkdir pytorch
cd pytorch
mkdir cifar10
cd cifar10

The installation of PyTorch is done via

conda install pytorch torchvision -c pytorch

Running the CIFAR-10 Tutorial tutorial via jupyter notebook

I did the CIFAR-10 classifier tutorial via a jupyter notebook. Jupyter notebook is a webfrontend such that the python code can be executed via a webbrowser. To install the jupyter framework I installed

conda install notebook

When I try to run the jupyter notebook, this fails in my installation due to a problem with tornado version 5.0. It looks like this:

beckmanf@breakout:~/pytorch/cifar10$ jupyter notebook
Traceback (most recent call last):
  File "/rz2home/beckmanf/miniconda2/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/rz2home/beckmanf/miniconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 45, in <module>
    ioloop.install()
  File "/rz2home/beckmanf/miniconda2/lib/python2.7/site-packages/zmq/eventloop/ioloop.py", line 210, in install
    assert (not ioloop.IOLoop.initialized()) or \
AttributeError: type object 'IOLoop' has no attribute 'initialized'
beckmanf@breakout:~/pytorch/cifar10$

So I used tornado version 4.5.3 instead of the default tornado 5.0 version

conda install tornado=4.5.3

Then I can start the jupyter notebook which will start a web server at some free port.

beckmanf@breakout:~/pytorch/cifar10$ jupyter notebook --no-browser
[I 11:59:55.306 NotebookApp] The port 8888 is already in use, trying another port.
[I 11:59:55.405 NotebookApp] Serving notebooks from local directory: /rz2home/beckmanf/pytorch/cifar10
[I 11:59:55.405 NotebookApp] 0 active kernels
[I 11:59:55.405 NotebookApp] The Jupyter Notebook is running at:
[I 11:59:55.405 NotebookApp] http://localhost:8889/?token=3d22f49d309a3e4fc0834dd58e3f7f36152d34e7a318aa3a
[I 11:59:55.405 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:59:55.405 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8889/?token=3d22f49d309a3e4fc0834dd58e3f7f36152d34e7a318aa3a

In this example the jupyter web server is at port number 8889 on the breakout. The breakout is configured such that this port can NOT be reached from outside. Therefore you have to tunnel this port via ssh to your client machine. So do the following on your client with your account name.

FriedrichsMacBook:~ fritz$ ssh -p 2222 -L 8889:localhost:8889 beckmanf@breakout.hs-augsburg.de

Now you can open the jupyter notebook via a local webbrowser on your client machine. The url is the one which was given above including the token.

  • breakout.1520427384.txt.gz
  • Last modified: 2018/03/07 13:56
  • by beckmanf