Configuration Alternatives at Runtime#
The OpenFold2 NIM allows alternative runtime configurations.
Start the OpenFold2 NIM#
To start the NIM:
export LOCAL_NIM_CACHE=~/.cache/nim
docker run --rm --name openfold2 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    nvcr.io/nim/openfold/openfold2:latest
Notes:
- The - -poption sets the port for the NIM.
- The - -eoptions define the environment variables, which are passed into the NIM’s container at runtime.
- --rmremoves the container when it exists.
- -itallows interacting with the container directly at the CLI.
Using an alternative port for OpenFold2 NIM requests#
If you have other HTTP servers running (for example, other NIMs), you may need to make the 8000 port available by using another port for your NIM. To use an alternative port:
- Change the exposed port by setting the - -poption.
- Set the - NIM_HTTP_API_PORTenvironment variable to the new port.
The following is an example of setting the NIM to run on port 7979:
export LOCAL_NIM_CACHE=/mount/largedisk/nim/.cache
docker run --rm --name openfold2 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e NIM_HTTP_API_PORT=7979 \ ## We must set the NIM_HTTP_API_PORT environment variable...
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 7979:7979 \ ## as well as forward the port to host.
    nvcr.io/nim/openfold/openfold2:latest
Running in Torch Mode#
By default, the NIM will run in TensorRT mode for supported GPUs. If you need to run the model directly in Torch mode instead, you can override the default backend optimization by setting the NIM_OPTIMIZED_BACKEND environment variable to torch.
The following is an example of setting the NIM to run in Torch mode:
export LOCAL_NIM_CACHE=~/.cache/nim
docker run --rm --name openfold2 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e NIM_OPTIMIZED_BACKEND=torch \ ## Set the backend to torch mode
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    nvcr.io/nim/openfold/openfold2:latest