Skip to content

parallel

Dask helper functions.

build_gpu_cycler(workers_per_gpu=1, n_gpus=nr_gpus())

Generator to cycle through GPU indices.

On machine with multiple GPUs and a computation that does not use a full GPU. This will yield GPU indices in a round-robin fashion.

  • If n_gpus is set to 0, it will yield 0 indefinitely.
  • If workers_per_gpu>0 and n_gpus=1, it will yield 0 indefinitely.
  • If workers_per_gpu=1 and n_gpus=2, it will yield 0, 1 indefinitely.
  • If workers_per_gpu=4 and n_gpus=2, it will yield 0, 1, 0, 1, 0, 1, 0, 1 indefinitely.

configure_dask_scheduler(scheduler_address, name, workers_per_gpu=0, nproc=1)

Configure the Dask scheduler by reusing existing or creating a new cluster.

When creating a local GPU cluster on a machine with multiple GPUs, it will start workers which each can only see a single GPU.

Parameters:

Name Type Description Default
scheduler_address str | Cluster | None

Address of the Dask scheduler to connect to, or None for local cluster.

required
name str

Name for the Dask cluster.

required
workers_per_gpu int

Number of workers per GPU. If > 0, a GPU cluster will be configured otherwise a CPU cluster.

0
nproc int

Number of processes to use per worker for CPU support.

1

Raises:

Type Description
ImportError

If GPU support is requested but pyopencl is not installed.

ValueError

If multiple GPUs are detected but the vendor is unsupported.

Returns:

Type Description
str | Cluster

A Dask Cluster instance or a string address for the scheduler.

nr_gpus()

The number of available GPUs on the system.

Returns:

Type Description
int

Number of GPUs available

powerfit_worker(pdb_file, density_map_target, powerfit_run_root_dir, options)

Worker function for running PowerFit on a single PDB file.

Parameters:

Name Type Description Default
pdb_file Path

Path to the PDB file to process

required
density_map_target Path

Path to the density map file

required
powerfit_run_root_dir Path

Root directory for PowerFit results

required
options PowerfitOptions

PowerFit options

required