-
Notifications
You must be signed in to change notification settings - Fork 2k
Using nvidia-docker from third-party tools #39
Comments
If the tool supports overriding the docker command, then you should use that to plug in If it's not possible, you can query the Docker CLI arguments to the plugin:
Of course you will need to transform this into YAML format for Thank you! |
If a sorf-of multiline variable substitution was possible in compose files, I guess you could add a YAML format option for the for the REST endpoint. But I think the environment variables are queried after the YAML syntax is parsed, resulting in "invalid mode" error from the improper structure. This still might be useful for just a 'copy and paste' approach for compose files though. Is there a way we could use the volume-driver option with say set label format to convey the card IDs to export? |
@ruffsl I like the idea of using the variable substitution. NV_DEVICES="['/dev/nvidia0', '/dev/nvidia1']" We could easily do something like (the same way eval "$(curl -s localhost:3476/docker/env)" given the following devices: ${NV_DEVICES} |
I'm just testing a foo bar example: test:
image: ubuntu
volumes: ${FOO_BAR}
command: ping 127.0.0.1 and am seeing this: $ mkdir /tmp/foo
$ mkdir /tmp/bar
$ export FOO_BAR="['/tmp/bar:/bar', '/tmp/foo:/foo']"
$ docker-compose up
ERROR: Validation failed in file './docker-compose.yml', reason(s):
Service 'test' configuration key 'volumes' contains an invalid type, it should be an array Is this the correct one-line YAML syntax? I've never seen it before. |
Not sure if For other volumes/devices if |
It seems to work without variable substitution:
Variable substitution might be designed to generate values, and not YAML. @ruffsl: I didn't understand the following, could you explain it?
|
@flx42 This was an example of what I was thinking test:
image: ubuntu
volume_driver: nvidia-docker-driver
labels:
nvidia.gpu: "0,1"
command: nvidia-smi I'm not sure how feasible this would be, but I think its attractive in its simplicity from a user perspective. You've developed a plugin, could a custom driver be extend to parse the label metadata? This then could be a clean way to define nvidia containers with compose. You could also use the variable substitution with this as well: labels:
nvidia.gpu: ${NV_GPU} |
A volume plugin will not be able to mount devices, and actually a plugin can't even inspect the starting image AFAIK. |
Good progress on docker/compose#2750 |
@flx42 is correct, currently the only supported plugin is |
Another vote here. I'm trying to get Kubernetes to talk to the plugin. Kubernetes doesn't build command lines, it uses a Docker client API (fsouza's, but there's a migration in progress to the official one). JSON might work. Or perhaps embedding parts of nvidia-docker and nvidia-docker-plugin as a library inside kubelet (the daemon that manages the node) or a helper process running on the same machine. |
I'm not really familiar with Kubernetes but we are definitively interested in supporting it. Since it's written in Go, the |
Nut now uses |
So is there method to use the nvidia plugin with docker-compose now, |
Well it's not working out of the box but with the addition of the #! /usr/bin/env python
import urllib2
import json
import yaml
import sys
if len(sys.argv) == 1:
print "usage: %s service [key=value]..." % sys.argv[0]
sys.exit(0)
resp = urllib2.urlopen("http://localhost:3476/docker/cli/json").read()
args = json.loads(resp)
args["volumes"] = args.pop("Volumes")
args["devices"] = args.pop("Devices")
args["volume_driver"] = args.pop("VolumeDriver")
doc = {sys.argv[1]: args}
for arg in sys.argv[2:]:
k, v = arg.split("=")
args[k] = v
yaml.safe_dump(doc, file('docker-compose.yml', 'w'), default_flow_style=False) ./compose.py cuda image=nvidia/cuda command=nvidia-smi
docker-compose up |
Whilst I appreciate this as a step in the right direction, this still isn't an ideal solution from my point of view. I'd like to see proper integration with docker-compose stay on the radar. |
Agreed this is not a canonical solution by any means. This issue should be reopened :/ |
@MadcowD I don't think there is much more we can do right now for a better integration. But it's still on our radar since we have people in our team using |
@3XX0 I am trying to use your docker compose example above with a version '2' docker-compose but I am running into difficulty. Here is my docker-compose file:
I get the following error:
Any thoughts? |
Last time I tried, I had to create the volume beforehand with |
Better than nothing. This worked for me. Steps:
docker-compose:
You should be able to generate this yaml file (and generate the volume) by modifying compose.py above. Thank you. |
FYI. I use a different solution that is a little easier to manage between machines. in the compose file I set an external driver as before, however, I give the service a static, common name, and set the name alias from variable interpolation like so:
then in my service, I use this common name (nvidia_driver)
All that remains is to set environment variable NVIDIA_DRIVER_VOLUME to your local driver name. This can be obtained from |
@jmerkow: @eywalker created a project called nvidia-docker-compose, we haven't tested it, but you might be interested to look at it. |
Another symptom is that I'd like to know what exactly
and afterwards loads the nvml C library while the nvidia-docker command is running. |
I've found that it's not actually hanging but becomes very very slow. (e.g., 10 sec in CPU or nvidia-docker vs. 92 sec in GPU with docker-py invocation) May be related to #224 ...? |
@achimnol We explain what The "bad volume format" error is a limitation of Docker, see #181. Finally, as I explained in #224, we have heard multiple users claiming their code was slower inside Docker, but every single time it was because they compiled the project with different flags, or they had different settings during execution. |
It's very easy to use
nvidia-docker
when running individual containers, but is there a way to runnvidia-docker
instead ofdocker
from other Docker tools likedocker-compose
, Tutum, Rancher, etc?I am assuming one would just need to specify the
nvidia-docker
volume to be mounted in the container, but I couldn't find any documentation on the correct syntax.The text was updated successfully, but these errors were encountered: