Deploy
The example commands are for Docker on a Linux host.
The microservice runs inside a container and uses NVIDIA’s Container Toolkit to access the GPU. The container launches a FastAPI frontend webservice and a multiprocess backend that manages the execution of jobs on each available GPU.
Launching and Configuring the Container
A minimal command to run the service is:
This command uses the following options:
-itlaunches the command in an interactive terminal.--rmdeletes the file system on exit.--runtime=nvidiaenables NVIDIA Container Toolkit support.-p 127.0.0.1:8000:8000exposes the webservice to a port accessible from the host.--pid=hostis optional and only required to track memory use.alchemi-vasp:latestis the name of the container image to run.
Add further configuration options by setting environment variables.
Ensure the service is only available to those licensed by VASP GmbH.
Providing POTCAR Files
Make POTCARs available to the microservice after building by mounting VASP
pseudopotential files (POTCARs) to /opt/potcar.
Mounting a POTCAR directory is optional. You can also supply POTCAR files when in the request to the microservice.
Directory Structure
The pseudopotential directory structure can contain multiple types of POTCARs as
separate subdirectories. For example, the following directory structure supplies
both PAW_GGA and PAW_GGA_54 as the potcar_type field.
POTCARs must be in a unique directory named after the element symbol and can be
compressed with a .Z extension.
The microservice expects the directories holding POTCAR types to follow a specific
naming format if requests use default pseudopotential sets. Name directories as
PAW_<functional>_<version> where “functional” is the name of the
functional (for example, PBE or LDA) and the version is a two-digit number (for
example, 64). For example, place the Be_sv pseudopotential for a PBE functional from
version 54 at ./PAW_PBE_54/Be_sv/POTCAR.
Authentication
The microservice uses bearer token authorization to ensure only authorized users are able to run VASP calculations.
Supply a pre-selected token via the ALCHEMI_SERVICE_TOKEN
environment variable on launching the container.
A random token will be generated then printed to the log file if no token is provided.
Running Multiple Replicas
The microservice must share a file system for several directories if running multiple replicas behind a load balancer:
/workspace/completedstores the output summaries and, if configured, output files for completed requests./workspace/inputsstores the input files for requests.
Every replica can retrieve files from the shared directories when required and deletes files when users request them.
File Management
The microservice manages input and output files separately, and both follow first-in-first-out (FIFO) deletion policies.
The microservice stores input files in the /workspace/inputs directory. You
can delete a specific input file (GET /input/delete/{file_id}) or files older
than a certain age (DELETE /input/purge). The microservice also deletes files
automatically when the number of files exceeds the configured limit, starting
with the oldest files.
The microservice stores results in the /workspace/completed directory. It
stores two types of files:
- Summary files (
{request_id}.json) are either empty placeholders for the results or a fully formed ready reply. - Output files (
{request_id}.tar) are the full output files from VASP.
The microservice deletes both types of files when a client successfully
retrieves them (for example, GET /result/{request_id} or
GET /files/{request_id}/download). It deletes output files if more than a
configured number are present in the directory, removing the oldest first.
Use the DELETE /status/purge and DELETE /files/purge endpoints to remove old
output files from the service.
For Multiple Replicas
Each replica manages its own output files. Each replica maintains its own FIFO queue for deleting unclaimed output files and old input files. As a consequence, the disk space required for the shared directories grows with the number of replicas.
Exposing Output Files to Clients
Allow clients to access the output files of a service directory by mounting the
/workspace/completed directory as a volume.
The --user $(id -u):$(id -g) option allows the container to write files with
the same user and group ID as the host user.
Logging Behavior
The service writes logs to standard output by default. An example log on a workstation with a single GPU is as follows:
The launch procedure is as follows:
- FastAPI initializes the driver which manages VASP calculations.
- The backend starts and configures itself according to the environment variables and available hardware.
- The frontend detects default configuration settings to use for all requests.
- The backend detects the CPU and GPU memory hierarchy and launches an executor process for each GPU using only the appropriate CPU cores for that GPU.
- The server is ready to accept requests.