Skip to content

Commit c54fb26

Browse files
committed
docs: how to enable nvidia gpu 2.0 in Pouch
Signed-off-by: codejuan <[email protected]>
1 parent a52c6f3 commit c54fb26

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

daemon/mgr/spec_nvidia_hook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

1111
var (
12+
// nvidiaHookName is a custom OCI prestart hook binary to runc in order to enable GPU containers.
1213
nvidiaHookName = "nvidia-container-runtime-hook"
1314
)
1415

daemon/mgr/spec_nvidia_hook_test.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313

1414
func Test_setNvidiaHook(t *testing.T) {
1515
nvidiaHookName = "test-nvidia-container-runtime-hook"
16-
installDir := "/usr/local/bin/"
16+
installDir := "/usr/local/bin"
17+
os.Setenv("PATH", installDir)
1718
fullname := path.Join(installDir, nvidiaHookName)
1819
os.Remove(fullname)
1920
os.Create(fullname)
@@ -69,8 +70,34 @@ func Test_setNvidiaHook(t *testing.T) {
6970
},
7071
},
7172
},
72-
// exec.LookPath("nvidia-container-runtime-hook") return error,
73-
[]specs.Hook{specs.Hook{
73+
[]specs.Hook{{
74+
Path: path,
75+
Args: append([]string{path}, "prestart"),
76+
}},
77+
},
78+
{
79+
"NvidiaConfig not nil, NvidiaEnv is null",
80+
&Container{
81+
HostConfig: &types.HostConfig{
82+
Resources: types.Resources{
83+
NvidiaConfig: &types.NvidiaConfig{
84+
NvidiaDriverCapabilities: "all",
85+
NvidiaVisibleDevices: "all",
86+
},
87+
},
88+
},
89+
Config: &types.ContainerConfig{
90+
Env: []string{},
91+
},
92+
},
93+
&SpecWrapper{
94+
s: &specs.Spec{
95+
Hooks: &specs.Hooks{
96+
Prestart: []specs.Hook{},
97+
},
98+
},
99+
},
100+
[]specs.Hook{{
74101
Path: path,
75102
Args: append([]string{path}, "prestart"),
76103
}},

docs/features/pouch_with_gpu.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# PouchContainer with GPU
2+
3+
NVIDIA uses containers to develop, test, benchmark, and deploy deep learning (DL) frameworks and HPC applications. A variety of customers used NVIDIA-Container-Runtime to containerize and run GPU accelerated workloads. The NVIDIA-Container-Runtime is the next-generation GPU-aware container runtime. It is compatible with the Open Containers Initiative (OCI) specification used by Pouch and other popular container technologies.
4+
5+
## nvidia gpu runtime
6+
7+
![pouch_with_pouch](../static_files/pouch_with_gpu.png)
8+
9+
The figure shows how the NVIDIA-Container-Runtime integrates into Pouch. We set a custom OCI prestart hook called nvidia-container-runtime-hook to runc in order to enable GPU containers.
10+
11+
## Prerequisites Installation
12+
13+
Make sure you have installed the NVIDIA driver
14+
15+
1. GNU/Linux x86_64 with kernel version > 3.10
16+
2. NVIDIA GPU with Architecture > Fermi (2.1)
17+
3. NVIDIA drivers ~= 361.93 (untested on older versions)
18+
19+
## Start GPU container
20+
21+
Pouch support 2 method to start GPU container
22+
23+
1. Via nvidia config API, [nvidiaconfig](https://github.com/alibaba/pouch/blob/master/docs/api/HTTP_API.md#nvidiaconfig)
24+
2. Via Environment variables, [nvidia-container-runtime-env](https://github.com/NVIDIA/nvidia-container-runtime#environment-variables-oci-spec)
25+
26+
### Via API
27+
28+
```shell
29+
pouch run -it --nvidia-capabilities=all --nvidia-visible-devs=all centos:7 bash
30+
```
31+
32+
### Via Environment variables
33+
34+
The NVIDIA Container Runtime uses environment variables in container images to specify a GPU accelerated container.
35+
36+
```shell
37+
pouch run -it -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all centos:7 bash
38+
```
50.8 KB
Loading

0 commit comments

Comments
 (0)