Environment Variables for AlphaFold2
You can use environment variables to configure the AlphaFold2 NIM at runtime. Pass these variables to the container with the -e option in the docker run command. Runtime configuration lets you tune NIM performance, take advantage of your unique hardware, and modify runtime behavior, such as the location of the NIM cache. For the first-run procedure, refer to the Quickstart Guide.
General Environment Variables
The following table describes the environment variables you can set to configure the AlphaFold2 NIM.
The product of NIM_PARALLEL_MSA_RUNNERS and NIM_PARALLEL_THREADS_PER_MSA should be less than or equal to the number of CPU cores available to the NIM. The default values of NIM_PARALLEL_MSA_RUNNERS=3 and NIM_PARALLEL_THREADS_PER_MSA=8 work well for most machines, and most users do not need to modify these variables.
The host environment variable LOCAL_NIM_CACHE sets the NIM cache location on the host file system, and CUDA_VISIBLE_DEVICES controls which GPU devices are visible to the container.
Review How to Start the NIM
The following command starts the NIM. The examples in this page build on it.
In this command:
- The
-poption sets the port for the NIM. - The
-eoptions define environment variables, which are passed into the NIM’s container at runtime. --rmremoves the container when it exits.-itallows interacting with the container directly at the CLI.
Configure the Location of the NIM Cache
The location of the NIM cache can be changed on both the local file system and within the NIM. This is useful when a larger drive is needed to store the model weights, for example.
To change the NIM cache location on the host file system, change the source mount in the preceding command, which is set in the environment variable LOCAL_NIM_CACHE:
This affects only the location outside the container. To change the location of the cache inside the container, you must:
- Mount the new destination path.
- Provide the new path in the
NIM_CACHE_PATHenvironment variable.
The following example moves the cache within the container to /workdir/cache/af2/:
Use an Alternative Port for NIM Requests
If you have other HTTP or gRPC servers running (for example, other NIMs), you might need to make the 8000 port available by using another port for your NIM. To do so:
- Change the exposed port by setting the
-poption. - Set the
NIM_HTTP_API_PORTenvironment variable to the new port.
The following example sets the NIM to run on port 7979:
Configure MSA Runners and Threads
The AlphaFold2 NIM has been optimized in many ways. One such optimization is the ability to tune the MSA process for better performance on your machine, based on the number of available CPU cores, the number of available GPUs, and your SSD speed.
Do not run the AlphaFold2 NIM on a machine that uses a hard disk drive for storage, as it significantly decreases the performance of the NIM.
There are two layers of tunable parallelism for MSA within the AlphaFold2 NIM, set by two different environment variables:
NIM_PARALLEL_MSA_RUNNERScontrols the coarse-grained parallelism of the MSA process.NIM_PARALLEL_THREADS_PER_MSAcontrols the number of threads used by each MSA process.
The product of NIM_PARALLEL_MSA_RUNNERS and NIM_PARALLEL_THREADS_PER_MSA should be less than or equal to the number of CPU cores available to the NIM.
For example, on a machine with 48 CPU cores, an appropriate setting would be:
This allocates three runners, each with 12 threads.
We do not recommend using more than four runners, and the number of threads per MSA should generally be between eight and 16.
To modify these variables at runtime, pass them as environment variables in the NIM startup command. For example, on a 32-core machine, you could set NIM_PARALLEL_MSA_RUNNERS to three and reduce NIM_PARALLEL_THREADS_PER_MSA to 10 so that the workloads fit the machine well:
Related Topics
Explore the following related topics: