Category: Computing

Torch

It is necessary that the required CUDA library is installed in the system, normally this is under ls -lad /usr/local/cuda*.

in a python project

First create a new uv project:

export UV_CACHE_DIR=/scratch/userdata/${USER}/CACHE
export UV_NO_CACHE=1

cd /scratch/userdata/${USER}

# uv will create a virtual env for each project
uv init new-uv-project
cd new-uv-project

Customize the file pyproject.toml:

[project]
# the following supports CUDA 12.8 w/ CUDNN 9.10.2.21
requires-python = ">=3.10,<=3.15"
dependencies = [
    "torch>=2.9,<=2.10",
    "torchvision",
    "torchaudio",
]

[tool.uv.sources]
torch = { index = "pytorch" }

[[tool.uv.index]]
name = "pytorch"
# experimental with 2.9 + 2.10
#url = "https://download.pytorch.org/whl/cu130"
# stable support
url = "https://download.pytorch.org/whl/cu128"
explicit = true

Now add packages defined in the pyproject.toml to the new project, the packages will be installed inside a virtual environment:

UV_PYTHON_DOWNLOADS="TRUE" uv sync

If CUDA is installed in a non-standard location, set PATH so that the nvcc you want to use can be found (e.g., export PATH=/usr/local/cuda-12.8/bin:$PATH).

Test if torch works with CUDA:

cat << EOF > torchtest.py
import torch
# run a general test
print("Run a general test:")
x = torch.rand(5, 3)
print(x)

# run CuDNN calculation
if torch.cuda.is_available():
    print("Run a GPU test:")
    device = torch.device("cuda")
    # Enable CuDNN, may fallback if not available?
    torch.backends.cudnn.enabled = True
    # Create a simple convolutional layer
    conv_layer = torch.nn.Conv2d(3, 64, kernel_size=3).to(device)
    input_tensor = torch.randn(1, 3, 224, 224).to(device)
    output = conv_layer(input_tensor)
    print(output)
    print("Convolution operation completed.")

# Check if CUDA is available
print("Cuda available?:")
print(torch.cuda.is_available())
# Check if CuDNN is enabled
print("CuDNN available?:")
print(torch.backends.cudnn.is_available())
EOF

uv run torchtest.py

Now you can write your code in this project folder, it maybe is a good idea to add this folder into a git repository (uv already took care of a .gitignore file).

Read more

Posted on

Sagemath

Since Fedora 39 sagemath is not included as a package anymore. There are several possibilities you can use sagemath on Fedora, let’s highlight two:

  • Using the offical docker image
  • Installing it with conda

Podman

sagemath commandline

As our installation provides a fully configured rootless podman configuration, you can for example use the following commands to run the sagemath image:

# connect to a central client
ssh ada-X
# start tmux, alternativly you can use screen
tmux
# create a .sage folder
mkdir $HOME/.sage

# run sage with your home mounted to /home/sage/mydata and a mounted .sage
podman run --user 0 -ti -v $HOME/.sage:/home/sage/.sage -v $HOME:/home/sage/mydata sagemath/sagemath:latest

# to detach from the tmux session use the following keystrokes
#CTRL+B then D

To add a additional folder you can put a other -v parameter, for example:

-v /userdata/username:/home/sage/mydata2
sagemath jupyter notebook

When you want to use the sage jupyter notebook, you can do the following:

# connect to a central client
ssh ada-X
# start tmux, alternativly you can use screen
tmux
# create a .sage folder
mkdir $HOME/.sage

# run sage jupyter on port 8888
podman run --user 0 -p 8888:8888 -v $HOME/.sage:/home/sage/.sage -v $HOME:/home/sage/mydata sagemath/sagemath:latest sage-jupyter --allow-root

# to detach from the tmux session use the following keystrokes
#CTRL+B then D

Then open a second terminal on your local machine and open ssh tunnel to the ada:

# port forward from to ada-X
ssh -t username@ada-X -L 8888:localhost:8888

# Open webbrowser using the url with token shown in the output.

Conda

Please follow the official installation instruction:

Read more

Posted on

Euler for D-MATH users

The D-MATH is shareholder of the following 2 shares on the Euler HPC cluster:

  • es_math (–> disappearing soon, see below)
  • ls_math

All users need to request the access supported by a member (Professor, Senior Scientist) of D-MATH.

Note: On 7 January 2026, we will transfer the resources of “es_math” to “ls_math”. This will lead to a more efficient Euler usage for our department. Concerned users will be informed separately.

Read more

Posted on

Jupyter Notebook

Euler Cluster

This service is made for developing and debugging your code, not to run your code on the cluster. If you wish to run it, please use the SLURM queue system. Please only request multiple cores if you are planning to run some code that can make use of multiple cores.

For more information go to the following website:

~/.config/euler/jupyterhub

I want to load a cluster module / I want to activate a virtualenv / Jupyterlab is missing some features

This script will be sourced (. ~/.config/euler/jupyterhub/jupyterlabrc) before starting any service.

cat << EOF > ~/.config/euler/jupyterhub/jupyterlabrc
module load stack
module load python_cuda
#module load sage
#jupyter kernelspec install --user $SAGE_EULER_ROOT/share/jupyter/kernels
EOF

Compute Clients (ada-X) and Linux Desktops

First you need to create a new uv project and install jupyter into it:

export UV_CACHE_DIR=/scratch/userdata/${USER}/CACHE
export UV_NO_CACHE=1
cd /scratch/userdata/${USER}

# uv will create a virtual env for each project
uv init new-uv-project

Now add packages to the new project, the packages will be installed inside a virtual environment:

cd new-uv-project

# when inside the project uv will recognize and use the virtual env
uv add notebook

To run jupyter you can use the following:

uv run --with jupyter jupyter lab --no-browser

Port forwarding setup for Compute Clients

If you like to run it on our “central clients” (ada-X) you need to do a port forwarding, to have access to the notebook.

There are some requirements:

The following command will start a new jupyter notebook and open a ssh tunnel.

You need to modify the following in the command:

  • HOST="ada-10" with the host you like
  • USERNAME="username" with your username to connect.

The list of hosts you can use is on the following page:

HOST="ada-22"; USERNAME="${USER}"; PORT=$(($RANDOM % 1000 + 8000)); ssh -t $USERNAME@$HOST -L $PORT:localhost:$PORT "screen cd /scratch/userdata/${USER}/new-uv-project; uv run --with jupyter jupyter lab --no-browser --port $PORT"

You need to keep the terminal window running otherwise the port forwarding will stop. The notebook however will still be running on the “central client”, you will just loose the connection in to the webinterface.


To be able to connect to it again, it get’s a bit tricky, you need to know on which port you have started the notebook and reopen a port forwarding to it.

This can be done with the following command (you need to modify HOST=, USERNAME= and PORT=):

HOST="ada-22"; USERNAME="username"; PORT=8943; ssh $USERNAME@$HOST -L $PORT:localhost:$PORT

Read more

Posted on

Howto use docker at D-MATH

To use docker at D-MATH is to use podman -> https://podman.io/

With podman you can use all docker commands just write podman instead of docker in the command, all the parameter stay the same.

With podman we are able to provide a possibility that a user without administrative rights can download and run docker images.

Example 1

The following example will run the latest docker image of alpine linux (https://hub.docker.com/_/alpine).

podman run -ti -v $(pwd):/home/test alpine:latest

The parameter

  • -v $(pwd):/home/test

is very helpful, this will add the current folder you are in now, to the container at /home/test. If you have seLinux activated you need to add a Z:

  • -v $(pwd):/home/test:Z

Example 2

The following example shows howto run a more complicated docker image named fenics and transfer files.

First open a terminal and go into the folder which you want to have accessable in the docker image.

mkdir -p ~/Documents/mydata
cd ~/Documents/mydata

Now run the container with the following parameters:

podman run -ti -p 127.0.0.1:8000:8000 -v $(pwd):/home/fenics/shared -w /home/fenics/shared quay.io/fenicsproject/stable:current

This will connect you to the container.

But the docker image of the fenicsproject will log you in a user fenics, this user will not have access to the data in ~/Documents/mydata.

With podman the user root in the container will have access to your files.

So you need to become root inside the container to have access:

sudo su -

Read more

Posted on

Linux Environment Modules at the D-MATH

With Environment Modules or simply called Modules it is possible to dynamically expand the active user environment and to remove it again without closing the shell.

Read more

Posted on ,

Using “screen” to run simulations on a remote host

The suggested way to run your simulations on a remote host (let say for instance on ada-18) is to use screen, which allows you to:

  • use multiple shell windows from a single SSH session
  • keep a shell active even through network disruptions
  • disconnect and re-connect to a shell sessions from multiple locations
  • run a long running process without maintaining an active shell session.

Read more

Posted on ,

Tensorflow

To be able to use tensorflow you need to install it for your project. We recommend to use uv for creating your tensorflow python project.

Setup your project

uv will create and use a python virtual environment transparently so there is no need to create one seperatly. Use the storage on /scratch/userdata/$USER for your project, this is on the local disk of the ada-Xs as not all have the same python versions so the virtual environment must be recreated for every ada-X.

Initialize the project

export UV_NO_CACHE=1
cd /scratch/userdata/$USER

uv init new-uv-project

Install tensorflow and cuda in the project

cd /scratch/userdata/$USER/new-uv-project
uv add tensorflow[and-cuda]

# if you didn't set UV_NO_CACHE your cache could be big.
uv cache clean

Run your python code

To run you need to use uv you cannot simply use python as this will not load the virtual environment:

cd /scratch/userdata/$USER/new-uv-project
uv run main.py

Read more

Posted on , 2 Comments

Central Clients of D-MATH

Central Clients are powerful computers in the server room, running Fedora. The software available is the same as on the Linux desktops at the D-MATH. We distinguish between two types of Central Clients: Compute Clients and Load Clients.

Read more

Posted on ,

PROTECT YOUR BRAINWORK.

An IT Security Initiative
https://itsecurity.ethz.ch

Trending

Categories

Recent Posts