Docker build with NVIDIA runtime such as “--gpus” flag

I recently build docker container for machine learning project, which needs to build with some libraries depend on NVIDIA runtime.
I’d like to prepare fully setup container by docker build but I failed because NVIDIA runtime is no available while docker build , which doesn’t provide --gpus flag.
Is there any way to use NVIDIA runtime when docker build ??

I’m not even sure here is proper place to ask this question. if not, please let me know where it is.

Hi, I’m running into this exact same issue. Were you ever able to find a solution or workaround? Only thing I can come up with is running the base image with the GPU enabled, doing the necessary commands, then committing that as a new base image for the dockerfile I’m trying to enabled. That’s not ideal as a long term solution though.