实用程序#

NIM 包含一组实用程序脚本,以协助 NIM 操作。

实用程序可以通过将所需实用程序的名称添加到 docker run 命令来启动。例如,您可以使用以下命令执行 list-model-profiles 实用程序

docker run --rm --runtime=nvidia --gpus=all \
  --entrypoint list-model-profiles \
  nvcr.io/nim/nvidia/genmol:1.0.0

您可以使用 -h 标志获取有关每个实用程序的更多信息

docker run --rm --runtime=nvidia --gpus=all \
  --entrypoiint download-to-cache \
  nvcr.io/nim/nvidia/genmol:1.0.0 \
  -h

列出可用的模型配置文件#

将 NIM 检测到的系统信息以及所选 NIM 的所有配置文件列表打印到控制台。配置文件根据其是否与当前系统兼容进行分类,基于检测到的系统信息。

list-model-profiles

示例#

docker run -it --rm --gpus all -e NIM_LOG_LEVEL=WARNING \
  --entrypoint list-model-profiles \
  nvcr.io/nim/nvidia/genmol:1.0.0
SYSTEM INFO
- Free GPUs:
  -  [2230:10de] (0) NVIDIA RTX A6000 [current utilization: 2%]
  -  [2230:10de] (1) NVIDIA RTX A6000 [current utilization: 3%]
MODEL PROFILES
- All profiles:
    - a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036 (type=bert)

将模型配置文件下载到 NIM 缓存#

将选定或默认模型配置文件下载到 NIM 缓存。可用于在部署前预缓存配置文件。需要在环境中使用 NGC_API_KEYLOCAL_NIM_CACHE。文件夹 $LOCAL_NIM_CACHE 需要是可写的(模式为 777)。

download-to-cache

  --all 
        Set this to download all profiles to cache

  --profiles [PROFILES ...], -p [PROFILES ...] 
        Profile(s) to download. If none are provided, 
        the optimal profile is downloaded. Multiple 
        profiles can be specified separated by spaces.

示例#

docker run -it --rm --gpus all -e NGC_API_KEY -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
  --entrypoint download-to-cache \
  nvcr.io/nim/nvidia/genmol:1.0.0 \
  -p a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036
"timestamp": "2024-12-17 07:14:22,524", "level": "INFO", "message": "Fetching contents for profile a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036"
"timestamp": "2024-12-17 07:14:22,524", "level": "INFO", "message": "{
  "type": "bert"
}"
"timestamp": "2024-12-17 07:14:22,524", "level": "INFO", "message": "Using the profile specified by the user: a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036"
"timestamp": "2024-12-17 07:14:22,524", "level": "INFO", "message": "Downloading manifest profile: a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036"
tokenizer.json [00:00:00] [█████████████████████████████████████████████████████████████████████████████████] 45.23 KiB/45.23 KiB 2.12 MiB/s (0s)
model.ckpt [00:00:03] [█████████████████████████████████████████████████████████████████████████████████] 338.59 MiB/338.59 MiB 106.88 MiB/s (0s)

创建模型存储#

从缓存的模型配置文件中提取文件并创建一个格式正确的目录。如果配置文件尚未缓存,则会将其下载到模型缓存。下载配置文件需要在环境中使用 NGC_API_KEY

create-model-store

  --profile <PROFILE>, -p <PROFILE>
        Profile hash to create a model directory of. 
        Will be downloaded if not present.


  --model-store <MODEL_STORE>, -m <MODEL_STORE>
        Directory path where model {option}`--profile` 
        will be extracted and copied to.

示例#

docker run -it --rm --gpus all -e NGC_API_KEY -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
  --entrypoint create-model-store \
  nvcr.io/nim/nvidia/genmol:1.0.0 \
  -p a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036 -m /tmp
"timestamp": "2024-12-17 07:18:41,484", "level": "INFO", "message": "Fetching contents for profile a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036"
"timestamp": "2024-12-17 07:18:41,484", "level": "INFO", "message": "Using the default model_cache_path: /opt/nim/workspace"
"timestamp": "2024-12-17 07:18:41,484", "level": "INFO", "message": "Creating model store at /tmp"
model.ckpt [00:00:03] [█████████████████████████████████████████████████████████████████████████████████████████████████████████████████] 338.59 MiB/338.59 MiB 106.80 MiB/s (0s)tokenizer.json [00:00:00] [█████████████████████████████████████████████████████████████████████████████████████████████████████████████████] 45.23 KiB/45.23 KiB 2.81 MiB/s (0s)"timestamp": "2024-12-17 07:18:45,697", "level": "INFO", "message": "Copying contents for profile a525212dd4373ace3be568a38b5d189a6fb866e007adf56e750ccd11e896b036 to /tmp"

检查 NIM 缓存#

检查 NIM 缓存目录是否存在且可写入。

nim-llm-check-cache-env

示例#

docker run -it --rm --gpus all -v /bad_path:/opt/nim/.cache \
  --entrypoint nim-llm-check-cache-env \
  nvcr.io/nim/nvidia/genmol:1.0.0
The NIM cache directory /opt/nim/.cache is read-only. Application could fail if the model is not already present in the cache.

设置缓存环境变量#

将用于设置缓存环境变量的命令打印到控制台。

nim-llm-set-cache-env

示例#

docker run -it --rm --gpus all \
  --entrypoint nim-llm-set-cache-env \
  nvcr.io/nim/nvidia/genmol:1.0.0
export NGC_HOME=/opt/nim/.cache/ngc/hub
export HF_HOME=/opt/nim/.cache/huggingface