nvidia-docker run与docker run --runtime=nvidia是否存在差异?
nvidia-docker run and docker run --runtime=nvidia Different? Great question—this is a super common point of confusion, and it all boils down to how NVIDIA's Docker integration has evolved over time. Let’s break it down clearly:
Core Functionality: They’re Effectively Equivalent
At the end of the day, both commands do the exact same thing: launch a Docker container that can access your NVIDIA GPU resources. The end result (a GPU-enabled container running with all necessary drivers and libraries) is identical no matter which command you use.
Key Differences: Historical Context & Implementation
nvidia-docker run: This was the go-to command back in the nvidia-docker 1.x era. Back then, NVIDIA’s GPU support for Docker wasn’t integrated into Docker’s native runtime system, so a separatenvidia-dockerCLI tool was required to handle GPU setup, driver mounting, and container launch.docker run --runtime=nvidia: This became the standard with nvidia-docker 2.x and later. NVIDIA shifted to building their GPU support as a Docker runtime plugin, which meant you could use regular Docker commands with the--runtime=nvidiaflag to enable GPU access. The oldnvidia-dockerCLI was reworked to act as a wrapper—it actually translatesnvidia-docker runintodocker run --runtime=nvidia(plus some default configurations) under the hood.
Official Recommendation
NVIDIA’s current documentation favors docker run --runtime=nvidia (and even newer flags like docker run --gpus all for Docker 19.03+) because it aligns better with Docker’s native workflow. You don’t need to rely on a separate CLI tool, and it’s more consistent with how you’d run other specialized containers.
Compatibility Notes
- If you’re stuck on an older nvidia-docker 1.x installation, you’ll have to use
nvidia-docker runsince the runtime plugin doesn’t exist in that version. - For nvidia-docker 2.x and above, both commands work, but using
--runtime=nvidiais the more future-proof choice. You’ll still seenvidia-docker runin older tutorials or legacy scripts, but it’s just a holdover from the earlier tooling.
内容的提问来源于stack exchange,提问作者Rutger Hofste

