You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(dockerutil): GetImageMetadata: detect correct usr lib dir based on os release (#127)
We had been mounting GPU libraries into the destination /usr/lib inside the inner container by default. This doesn't hold true for Redhat-based distributions, who use /usr/lib64 instead.
- Adds the capability to sniff /etc/os-release inside the inner container
- Modifies the destination path for bind-mounting GPU libraries to the inner container based on the detected OS release ID
- Adds integration testing for Envbox+NVidia GPUs (not run by default in CI)
- Attempts to automatically set CODER_USR_LIB_DIR if not specified.
- Adds the capability to manually set the inner mount path via CODER_INNER_USR_LIB_DIR.
Copy file name to clipboardExpand all lines: README.md
+53-3Lines changed: 53 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ The environment variables can be used to configure various aspects of the inner
21
21
|`CODER_DOCKER_BRIDGE_CIDR`| The bridge CIDR to start the Docker daemon with. | false |
22
22
|`CODER_MOUNTS`| A list of mounts to mount into the inner container. Mounts default to `rw`. Ex: `CODER_MOUNTS=/home/coder:/home/coder,/var/run/mysecret:/var/run/mysecret:ro`| false |
23
23
|`CODER_USR_LIB_DIR`| The mountpoint of the host `/usr/lib` directory. Only required when using GPUs. | false |
24
+
|`CODER_INNER_USR_LIB_DIR`| The inner /usr/lib mountpoint. This is automatically detected based on `/etc/os-release` in the inner image, but may optionally be overridden. | false |
24
25
|`CODER_ADD_TUN`| If `CODER_ADD_TUN=true` add a TUN device to the inner container. | false |
25
26
|`CODER_ADD_FUSE`| If `CODER_ADD_FUSE=true` add a FUSE device to the inner container. | false |
26
27
|`CODER_ADD_GPU`| If `CODER_ADD_GPU=true` add detected GPUs and related files to the inner container. Requires setting `CODER_USR_LIB_DIR` and mounting in the hosts `/usr/lib/` directory. | false |
@@ -43,7 +44,7 @@ It is not possible to develop `envbox` effectively using a containerized environ
43
44
44
45
If a login is required to pull images from a private repository, create a secret following the instructions from the [Kubernetes Documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line) as such:
Then reference the secret in your template as such:
55
56
56
-
```
57
+
```shell
57
58
env {
58
59
name = "CODER_IMAGE_PULL_SECRET"
59
60
value_from {
@@ -93,11 +94,60 @@ When passing through GPUs to the inner container, you may end up using associate
93
94
94
95
Envbox will detect these mounts and pass them inside the inner container it creates, so that GPU-aware tools run inside the inner container can still utilize these libraries.
95
96
97
+
Here's an example Docker command to run a GPU-enabled workload in Envbox. Note the following:
98
+
99
+
1) The NVidia container runtime must be installed on the host (`--runtime=nvidia`).
100
+
2) `CODER_ADD_GPU=true` must be set to enable GPU-specific functionality.
101
+
3) When `CODER_ADD_GPU` is set, it is required to also set `CODER_USR_LIB_DIR` to a location where the relevant host directory has been mounted inside the outer container. In the below example, this is `/usr/lib/x86_64-linux-gnu` on the underlying host. It is mounted into the container under the path `/var/coder/usr/lib`. We then set `CODER_USR_LIB_DIR=/var/coder/usr/lib`. The actual location inside the container is not important **as long as it does not overwrite any pre-existing directories containing system libraries**.
102
+
4) The location to mount the libraries in the inner container is determined by the distribution ID in the `/etc/os-release` of the inner container. If the automatically determined location is incorrect (e.g. `nvidia-smi` complains about not being able to find libraries), you can set it manually via `CODER_INNER_USR_LIB_DIR`.
103
+
104
+
> Note: this step is required in case user workloads require libraries from the underlying host that are not added in by the container runtime.
cliflag.StringVarP(cmd.Flags(), &flags.boostrapScript, "boostrap-script", "", EnvBootstrap, "", "The script to use to bootstrap the container. This should typically install and start the agent.")
371
373
cliflag.StringVarP(cmd.Flags(), &flags.containerMounts, "mounts", "", EnvMounts, "", "Comma separated list of mounts in the form of '<source>:<target>[:options]' (e.g. /var/lib/docker:/var/lib/docker:ro,/usr/src:/usr/src).")
372
374
cliflag.StringVarP(cmd.Flags(), &flags.hostUsrLibDir, "usr-lib-dir", "", EnvUsrLibDir, "", "The host /usr/lib mountpoint. Used to detect GPU drivers to mount into inner container.")
375
+
cliflag.StringVarP(cmd.Flags(), &flags.innerUsrLibDir, "inner-usr-lib-dir", "", EnvInnerUsrLibDir, "", "The inner /usr/lib mountpoint. This is automatically detected based on /etc/os-release in the inner image, but may optionally be overridden.")
373
376
cliflag.StringVarP(cmd.Flags(), &flags.dockerConfig, "docker-config", "", EnvDockerConfig, "/root/.docker/config.json", "The path to the docker config to consult when pulling an image.")
374
377
cliflag.BoolVarP(cmd.Flags(), &flags.addTUN, "add-tun", "", EnvAddTun, false, "Add a TUN device to the inner container.")
375
378
cliflag.BoolVarP(cmd.Flags(), &flags.addFUSE, "add-fuse", "", EnvAddFuse, false, "Add a FUSE device to the inner container.")
0 commit comments