Environment Variables

vLLM uses the following environment variables to configure the system:

Warning

Please note that VLLM_PORT and VLLM_HOST_IP set the port and ip for vLLM’s internal usage. It is not the port and ip for the API server. If you use --host $VLLM_HOST_IP and --port $VLLM_PORT to start the API server, it will not work.

All environment variables used by vLLM are prefixed with VLLM_. Special care should be taken for Kubernetes users: please do not name the service as vllm, otherwise environment variables set by Kubernetes might conflict with vLLM’s environment variables, because Kubernetes sets environment variables for each service with the capitalized service name as the prefix.

  1. environment_variables: Dict[str, Callable[[], Any]] = {
  2. # ================== Installation Time Env Vars ==================
  3. # Target device of vLLM, supporting [cuda (by default),
  4. # rocm, neuron, cpu, openvino]
  5. "VLLM_TARGET_DEVICE":
  6. lambda: os.getenv("VLLM_TARGET_DEVICE", "cuda"),
  7. # Maximum number of compilation jobs to run in parallel.
  8. # By default this is the number of CPUs
  9. "MAX_JOBS":
  10. lambda: os.getenv("MAX_JOBS", None),
  11. # Number of threads to use for nvcc
  12. # By default this is 1.
  13. # If set, `MAX_JOBS` will be reduced to avoid oversubscribing the CPU.
  14. "NVCC_THREADS":
  15. lambda: os.getenv("NVCC_THREADS", None),
  16. # If set, vllm will use precompiled binaries (*.so)
  17. "VLLM_USE_PRECOMPILED":
  18. lambda: bool(os.environ.get("VLLM_USE_PRECOMPILED")),
  19. # CMake build type
  20. # If not set, defaults to "Debug" or "RelWithDebInfo"
  21. # Available options: "Debug", "Release", "RelWithDebInfo"
  22. "CMAKE_BUILD_TYPE":
  23. lambda: os.getenv("CMAKE_BUILD_TYPE"),
  24. # If set, vllm will print verbose logs during installation
  25. "VERBOSE":
  26. lambda: bool(int(os.getenv('VERBOSE', '0'))),
  27. # Root directory for VLLM configuration files
  28. # Defaults to `~/.config/vllm` unless `XDG_CONFIG_HOME` is set
  29. # Note that this not only affects how vllm finds its configuration files
  30. # during runtime, but also affects how vllm installs its configuration
  31. # files during **installation**.
  32. "VLLM_CONFIG_ROOT":
  33. lambda: os.path.expanduser(
  34. os.getenv(
  35. "VLLM_CONFIG_ROOT",
  36. os.path.join(get_default_config_root(), "vllm"),
  37. )),
  38. # ================== Runtime Env Vars ==================
  39. # Root directory for VLLM cache files
  40. # Defaults to `~/.cache/vllm` unless `XDG_CACHE_HOME` is set
  41. "VLLM_CACHE_ROOT":
  42. lambda: os.path.expanduser(
  43. os.getenv(
  44. "VLLM_CACHE_ROOT",
  45. os.path.join(get_default_cache_root(), "vllm"),
  46. )),
  47. # used in distributed environment to determine the ip address
  48. # of the current node, when the node has multiple network interfaces.
  49. # If you are using multi-node inference, you should set this differently
  50. # on each node.
  51. 'VLLM_HOST_IP':
  52. lambda: os.getenv('VLLM_HOST_IP', "") or os.getenv("HOST_IP", ""),
  53. # used in distributed environment to manually set the communication port
  54. # Note: if VLLM_PORT is set, and some code asks for multiple ports, the
  55. # VLLM_PORT will be used as the first port, and the rest will be generated
  56. # by incrementing the VLLM_PORT value.
  57. # '0' is used to make mypy happy
  58. 'VLLM_PORT':
  59. lambda: int(os.getenv('VLLM_PORT', '0'))
  60. if 'VLLM_PORT' in os.environ else None,
  61. # path used for ipc when the frontend api server is running in
  62. # multi-processing mode to communicate with the backend engine process.
  63. 'VLLM_RPC_BASE_PATH':
  64. lambda: os.getenv('VLLM_RPC_BASE_PATH', tempfile.gettempdir()),
  65. # If true, will load models from ModelScope instead of Hugging Face Hub.
  66. # note that the value is true or false, not numbers
  67. "VLLM_USE_MODELSCOPE":
  68. lambda: os.environ.get("VLLM_USE_MODELSCOPE", "False").lower() == "true",
  69. # Instance id represents an instance of the VLLM. All processes in the same
  70. # instance should have the same instance id.
  71. "VLLM_INSTANCE_ID":
  72. lambda: os.environ.get("VLLM_INSTANCE_ID", None),
  73. # Interval in seconds to log a warning message when the ring buffer is full
  74. "VLLM_RINGBUFFER_WARNING_INTERVAL":
  75. lambda: int(os.environ.get("VLLM_RINGBUFFER_WARNING_INTERVAL", "60")),
  76. # path to cudatoolkit home directory, under which should be bin, include,
  77. # and lib directories.
  78. "CUDA_HOME":
  79. lambda: os.environ.get("CUDA_HOME", None),
  80. # Path to the NCCL library file. It is needed because nccl>=2.19 brought
  81. # by PyTorch contains a bug: https://github.com/NVIDIA/nccl/issues/1234
  82. "VLLM_NCCL_SO_PATH":
  83. lambda: os.environ.get("VLLM_NCCL_SO_PATH", None),
  84. # when `VLLM_NCCL_SO_PATH` is not set, vllm will try to find the nccl
  85. # library file in the locations specified by `LD_LIBRARY_PATH`
  86. "LD_LIBRARY_PATH":
  87. lambda: os.environ.get("LD_LIBRARY_PATH", None),
  88. # flag to control if vllm should use triton flash attention
  89. "VLLM_USE_TRITON_FLASH_ATTN":
  90. lambda: (os.environ.get("VLLM_USE_TRITON_FLASH_ATTN", "True").lower() in
  91. ("true", "1")),
  92. # Internal flag to enable Dynamo graph capture
  93. "VLLM_TEST_DYNAMO_GRAPH_CAPTURE":
  94. lambda: int(os.environ.get("VLLM_TEST_DYNAMO_GRAPH_CAPTURE", "0")),
  95. # local rank of the process in the distributed setting, used to determine
  96. # the GPU device id
  97. "LOCAL_RANK":
  98. lambda: int(os.environ.get("LOCAL_RANK", "0")),
  99. # used to control the visible devices in the distributed setting
  100. "CUDA_VISIBLE_DEVICES":
  101. lambda: os.environ.get("CUDA_VISIBLE_DEVICES", None),
  102. # timeout for each iteration in the engine
  103. "VLLM_ENGINE_ITERATION_TIMEOUT_S":
  104. lambda: int(os.environ.get("VLLM_ENGINE_ITERATION_TIMEOUT_S", "60")),
  105. # API key for VLLM API server
  106. "VLLM_API_KEY":
  107. lambda: os.environ.get("VLLM_API_KEY", None),
  108. # S3 access information, used for tensorizer to load model from S3
  109. "S3_ACCESS_KEY_ID":
  110. lambda: os.environ.get("S3_ACCESS_KEY_ID", None),
  111. "S3_SECRET_ACCESS_KEY":
  112. lambda: os.environ.get("S3_SECRET_ACCESS_KEY", None),
  113. "S3_ENDPOINT_URL":
  114. lambda: os.environ.get("S3_ENDPOINT_URL", None),
  115. # Usage stats collection
  116. "VLLM_USAGE_STATS_SERVER":
  117. lambda: os.environ.get("VLLM_USAGE_STATS_SERVER", "https://stats.vllm.ai"),
  118. "VLLM_NO_USAGE_STATS":
  119. lambda: os.environ.get("VLLM_NO_USAGE_STATS", "0") == "1",
  120. "VLLM_DO_NOT_TRACK":
  121. lambda: (os.environ.get("VLLM_DO_NOT_TRACK", None) or os.environ.get(
  122. "DO_NOT_TRACK", None) or "0") == "1",
  123. "VLLM_USAGE_SOURCE":
  124. lambda: os.environ.get("VLLM_USAGE_SOURCE", "production"),
  125. # Logging configuration
  126. # If set to 0, vllm will not configure logging
  127. # If set to 1, vllm will configure logging using the default configuration
  128. # or the configuration file specified by VLLM_LOGGING_CONFIG_PATH
  129. "VLLM_CONFIGURE_LOGGING":
  130. lambda: int(os.getenv("VLLM_CONFIGURE_LOGGING", "1")),
  131. "VLLM_LOGGING_CONFIG_PATH":
  132. lambda: os.getenv("VLLM_LOGGING_CONFIG_PATH"),
  133. # this is used for configuring the default logging level
  134. "VLLM_LOGGING_LEVEL":
  135. lambda: os.getenv("VLLM_LOGGING_LEVEL", "INFO"),
  136. # Trace function calls
  137. # If set to 1, vllm will trace function calls
  138. # Useful for debugging
  139. "VLLM_TRACE_FUNCTION":
  140. lambda: int(os.getenv("VLLM_TRACE_FUNCTION", "0")),
  141. # Backend for attention computation
  142. # Available options:
  143. # - "TORCH_SDPA": use torch.nn.MultiheadAttention
  144. # - "FLASH_ATTN": use FlashAttention
  145. # - "XFORMERS": use XFormers
  146. # - "ROCM_FLASH": use ROCmFlashAttention
  147. # - "FLASHINFER": use flashinfer
  148. "VLLM_ATTENTION_BACKEND":
  149. lambda: os.getenv("VLLM_ATTENTION_BACKEND", None),
  150. # If set, vllm will use flashinfer sampler
  151. "VLLM_USE_FLASHINFER_SAMPLER":
  152. lambda: bool(int(os.getenv("VLLM_USE_FLASHINFER_SAMPLER", "0"))),
  153. # Pipeline stage partition strategy
  154. "VLLM_PP_LAYER_PARTITION":
  155. lambda: os.getenv("VLLM_PP_LAYER_PARTITION", None),
  156. # (CPU backend only) CPU key-value cache space.
  157. # default is 4GB
  158. "VLLM_CPU_KVCACHE_SPACE":
  159. lambda: int(os.getenv("VLLM_CPU_KVCACHE_SPACE", "0")),
  160. # (CPU backend only) CPU core ids bound by OpenMP threads, e.g., "0-31",
  161. # "0,1,2", "0-31,33". CPU cores of different ranks are separated by '|'.
  162. "VLLM_CPU_OMP_THREADS_BIND":
  163. lambda: os.getenv("VLLM_CPU_OMP_THREADS_BIND", "all"),
  164. # OpenVINO key-value cache space
  165. # default is 4GB
  166. "VLLM_OPENVINO_KVCACHE_SPACE":
  167. lambda: int(os.getenv("VLLM_OPENVINO_KVCACHE_SPACE", "0")),
  168. # OpenVINO KV cache precision
  169. # default is bf16 if natively supported by platform, otherwise f16
  170. # To enable KV cache compression, please, explicitly specify u8
  171. "VLLM_OPENVINO_CPU_KV_CACHE_PRECISION":
  172. lambda: os.getenv("VLLM_OPENVINO_CPU_KV_CACHE_PRECISION", None),
  173. # Enables weights compression during model export via HF Optimum
  174. # default is False
  175. "VLLM_OPENVINO_ENABLE_QUANTIZED_WEIGHTS":
  176. lambda: bool(os.getenv("VLLM_OPENVINO_ENABLE_QUANTIZED_WEIGHTS", False)),
  177. # If the env var is set, then all workers will execute as separate
  178. # processes from the engine, and we use the same mechanism to trigger
  179. # execution on all workers.
  180. # Run vLLM with VLLM_USE_RAY_SPMD_WORKER=1 to enable it.
  181. "VLLM_USE_RAY_SPMD_WORKER":
  182. lambda: bool(int(os.getenv("VLLM_USE_RAY_SPMD_WORKER", "0"))),
  183. # If the env var is set, it uses the Ray's compiled DAG API
  184. # which optimizes the control plane overhead.
  185. # Run vLLM with VLLM_USE_RAY_COMPILED_DAG=1 to enable it.
  186. "VLLM_USE_RAY_COMPILED_DAG":
  187. lambda: bool(int(os.getenv("VLLM_USE_RAY_COMPILED_DAG", "0"))),
  188. # If the env var is set, it uses NCCL for communication in
  189. # Ray's compiled DAG. This flag is ignored if
  190. # VLLM_USE_RAY_COMPILED_DAG is not set.
  191. "VLLM_USE_RAY_COMPILED_DAG_NCCL_CHANNEL":
  192. lambda: bool(int(os.getenv("VLLM_USE_RAY_COMPILED_DAG_NCCL_CHANNEL", "1"))
  193. ),
  194. # Use dedicated multiprocess context for workers.
  195. # Both spawn and fork work
  196. "VLLM_WORKER_MULTIPROC_METHOD":
  197. lambda: os.getenv("VLLM_WORKER_MULTIPROC_METHOD", "fork"),
  198. # Path to the cache for storing downloaded assets
  199. "VLLM_ASSETS_CACHE":
  200. lambda: os.path.expanduser(
  201. os.getenv(
  202. "VLLM_ASSETS_CACHE",
  203. os.path.join(get_default_cache_root(), "vllm", "assets"),
  204. )),
  205. # Timeout for fetching images when serving multimodal models
  206. # Default is 5 seconds
  207. "VLLM_IMAGE_FETCH_TIMEOUT":
  208. lambda: int(os.getenv("VLLM_IMAGE_FETCH_TIMEOUT", "5")),
  209. # Timeout for fetching audio when serving multimodal models
  210. # Default is 5 seconds
  211. "VLLM_AUDIO_FETCH_TIMEOUT":
  212. lambda: int(os.getenv("VLLM_AUDIO_FETCH_TIMEOUT", "5")),
  213. # Path to the XLA persistent cache directory.
  214. # Only used for XLA devices such as TPUs.
  215. "VLLM_XLA_CACHE_PATH":
  216. lambda: os.path.expanduser(
  217. os.getenv(
  218. "VLLM_XLA_CACHE_PATH",
  219. os.path.join(get_default_cache_root(), "vllm", "xla_cache"),
  220. )),
  221. "VLLM_FUSED_MOE_CHUNK_SIZE":
  222. lambda: int(os.getenv("VLLM_FUSED_MOE_CHUNK_SIZE", "65536")),
  223. # If set, vllm will skip the deprecation warnings.
  224. "VLLM_NO_DEPRECATION_WARNING":
  225. lambda: bool(int(os.getenv("VLLM_NO_DEPRECATION_WARNING", "0"))),
  226. # If set, the OpenAI API server will stay alive even after the underlying
  227. # AsyncLLMEngine errors and stops serving requests
  228. "VLLM_KEEP_ALIVE_ON_ENGINE_DEATH":
  229. lambda: bool(os.getenv("VLLM_KEEP_ALIVE_ON_ENGINE_DEATH", 0)),
  230. # If the env var VLLM_ALLOW_LONG_MAX_MODEL_LEN is set, it allows
  231. # the user to specify a max sequence length greater than
  232. # the max length derived from the model's config.json.
  233. # To enable this, set VLLM_ALLOW_LONG_MAX_MODEL_LEN=1.
  234. "VLLM_ALLOW_LONG_MAX_MODEL_LEN":
  235. lambda:
  236. (os.environ.get("VLLM_ALLOW_LONG_MAX_MODEL_LEN", "0").strip().lower() in
  237. ("1", "true")),
  238. # If set, forces FP8 Marlin to be used for FP8 quantization regardless
  239. # of the hardware support for FP8 compute.
  240. "VLLM_TEST_FORCE_FP8_MARLIN":
  241. lambda:
  242. (os.environ.get("VLLM_TEST_FORCE_FP8_MARLIN", "0").strip().lower() in
  243. ("1", "true")),
  244. # Time in ms for the zmq client to wait for a response from the backend
  245. # server for simple data operations
  246. "VLLM_RPC_GET_DATA_TIMEOUT_MS":
  247. lambda: int(os.getenv("VLLM_RPC_GET_DATA_TIMEOUT_MS", "5000")),
  248. # If set, allow running the engine as a separate ray actor,
  249. # which is a deprecated feature soon to be removed.
  250. # See https://github.com/vllm-project/vllm/issues/7045
  251. "VLLM_ALLOW_ENGINE_USE_RAY":
  252. lambda:
  253. (os.environ.get("VLLM_ALLOW_ENGINE_USE_RAY", "0").strip().lower() in
  254. ("1", "true")),
  255. # a list of plugin names to load, separated by commas.
  256. # if this is not set, it means all plugins will be loaded
  257. # if this is set to an empty string, no plugins will be loaded
  258. "VLLM_PLUGINS":
  259. lambda: None if "VLLM_PLUGINS" not in os.environ else os.environ[
  260. "VLLM_PLUGINS"].split(","),
  261. # Enables torch profiler if set. Path to the directory where torch profiler
  262. # traces are saved. Note that it must be an absolute path.
  263. "VLLM_TORCH_PROFILER_DIR":
  264. lambda: (None if os.getenv("VLLM_TORCH_PROFILER_DIR", None) is None else os
  265. .path.expanduser(os.getenv("VLLM_TORCH_PROFILER_DIR", "."))),
  266. }