Search

Using docker in HTCondor

We use HTCondor when we do stochastic schrödinger equation (monte carlo solve in qutip)/ GPU jobs / parameter sweep. This tutorial contains 2 parts:

1) Creating a docker container 2) Using the docker container in HTCondor

Creating docker container

1. creating docker hub account

Docker Hub

2. Installing docker plugin to VSCode/Cursor:

Docker Plugin

3. Install docker desktop, open it and keep it running

https://www.docker.com/products/docker-desktop/

4. Create a Dockerfile that contain what you need in HTCondor job nodes

Here’s the example Dockerfile I used to install my package: https://github.com/JiakaiW/CoupledQuantumSystems/blob/main/Dockerfile

5. Build the image and push it to docker hub

In command line, run something like:

docker build -t name_of_image:name_of_tag .

Then in VScode, open the Docker plugin, (log in to your docker account if needed), then push it to docker hub

Using the docker container in HTCondor

Use VSCode to connect

(I recommand using VScode “connect to host” feature rather than connect to HTCondor using a terminal) VS Code SSH

Use container in submit file

This is my example submit file. The container_image contains the packages I need to use, and the specific task I want to do is contained in script.py.

container_image = docker://jiakaiw/coupledquantumsystems:v18
universe = container

log = darken_$(Cluster).log
error = darken_$(Process).err
# output = result_$(Process).zip

executable = shell.sh
arguments = $(Process)

should_transfer_files = YES
when_to_transfer_output = ON_EXIT
transfer_input_files = script.py

request_cpus = 3
request_memory = 6GB
request_disk = 3GB

queue 2601

My shell.sh is just a wrapper around python script:

python script.py $1