Skip to content

Commit 76cb2d5

Browse files
authored
[Doc] Add documentation for Docker images (#4778)
Describe some useful tips and best known methods for building DPC++ compiler inside Docker images.
1 parent 5a87b8c commit 76cb2d5

File tree

4 files changed

+188
-2
lines changed

4 files changed

+188
-2
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ sycl/ReleaseNotes.md @pvchupin @tfzhu
2626
sycl/doc/ @pvchupin @bader
2727
sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
2828
sycl/doc/extensions/SPIRV/ @AlexeySotkin @bashbaug @mbelicki
29+
sycl/doc/dev @bader @vladimirlaz
2930

3031
# Sub-groups
3132
sycl/include/CL/sycl/detail/spirv.hpp @Pennycook @AlexeySachkov

sycl/doc/GetStartedGuide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ and a wide range of compute accelerators such as GPU and FPGA.
4646
* Windows: `Visual Studio` version 15.7 preview 4 or later -
4747
[Download](https://visualstudio.microsoft.com/downloads/)
4848

49+
Alternatively, you can use Docker image, that has everything you need
50+
pre-installed:
51+
52+
```
53+
docker run --name sycl_build -it -v /local/workspace/dir/:/src ghcr.io/intel/llvm/ubuntu2004_base /bin/bash
54+
```
55+
56+
This command will start a terminal session, from which you can proceed with the
57+
instructions below. See [Docker BKMs](dev/DockerBKMs.md) for more info on Docker
58+
commands.
59+
4960
### Create DPC++ workspace
5061

5162
Throughout this document `DPCPP_HOME` denotes the path to the local directory

sycl/doc/dev/DockerBKMs.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Docker Containers BKMs
2+
3+
## Installation
4+
5+
Follow the [official guide](https://docs.docker.com/engine/install/) for your
6+
OS or distro.
7+
8+
### Change location of the images on the system
9+
10+
By default Docker stores images in `/var/lib/docker`, but that can be changed.
11+
12+
Create a new file called `/etc/docker/daemon.json` and put the following
13+
content:
14+
15+
```
16+
{
17+
"data-root": "/path/to/data/root",
18+
"exec-root": "/path/to/exec/root"
19+
}
20+
```
21+
22+
### Running Docker without sudo
23+
24+
Add your local user to `docker` group to be able to run docker commands without
25+
sudo.
26+
27+
28+
### Docker vs Podman
29+
30+
Docker and Podman are very similar tools, that allow you to manage and run
31+
container images. Unlike Docker, Podman runs without a daemon and allows you
32+
to run containers without root permissions. The command line syntax is mostly
33+
identical for Docker and Podman. Choose whatever is available on your system.
34+
35+
## SYCL Containers overview
36+
37+
The following containers are publicly available for DPC++ compiler development:
38+
39+
- `ghcr.io/intel/llvm/ubuntu2004_base`: contains basic environment setup for
40+
building DPC++ compiler from source.
41+
- `ghcr.io/intel/llvm/ubuntu2004_intel_drivers`: contains everything from the
42+
base container + pre-installed Intel drivers.
43+
- `ghcr.io/intel/llvm/sycl_ubuntu2004_nightly`: contains the latest successfully
44+
built nightly build of DPC++ compiler. The image comes in two flavors:
45+
with pre-installed Intel drivers (`latest`) and without them (`no-drivers`).
46+
47+
## Running Docker container interactively
48+
49+
The main application of Docker is containerizing services. But it also allows
50+
you to run containers interactively, so that you can use them as you would use a
51+
terminal or SSH session. The following command allows you to do that:
52+
53+
```
54+
docker run --name <friendly_name> -it <image_name>[:<tag>] /bin/bash
55+
```
56+
57+
This command will download an image if it does not exist locally. If you've
58+
downloaded an image previously, and you want to update it, use
59+
`docker pull <image_name>` command.
60+
61+
## Persisting data
62+
63+
### Persisting data with volumes
64+
65+
Docker container images are read-only. When container is destroyed, all its data
66+
is lost. To persist data when working with containers (i.e. when upgrading
67+
container version) one can use Docker volumes.
68+
69+
Creating a volume:
70+
71+
```
72+
docker volume create <volume name>
73+
```
74+
75+
Listing all volumes:
76+
77+
```
78+
docker volume list
79+
```
80+
81+
Mounting volume to the container:
82+
83+
```
84+
docker run <options> -v <volume_name>:/path/inside/container <image_name> bash
85+
```
86+
87+
Deleting a volume:
88+
89+
```
90+
docker volume rm <image_name>
91+
```
92+
93+
See [official documentation](https://docs.docker.com/storage/volumes/) for more
94+
info.
95+
96+
### Passthrough a directory to a container
97+
98+
Use `-v path/on/host:path/in/container` argument for `run` command to
99+
passthrough a host directory or a file.
100+
101+
## GPU passthrough
102+
103+
### Intel
104+
105+
Add `--device=/dev/dri` argument to `run` command to passthrough you Intel GPU.
106+
Make sure you're a member of `video` group to be able to access GPU.
107+
108+
### AMD
109+
110+
Follow the [official guide](https://rocmdocs.amd.com/en/latest/ROCm_Virtualization_Containers/ROCm-Virtualization-&-Containers.html).
111+
112+
### Nvidia
113+
114+
Follow [these](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html)
115+
instructions.
116+
117+
## Changing Docker user
118+
119+
By default all processes inside Docker run as root. Some LLVM or Clang tests
120+
expect your user to be anything but root. You can change the user by specifying
121+
`-u <username or uid>` option. All Docker containers come with user `sycl`
122+
created.
123+
124+
## Managing downloaded Docker images
125+
126+
List local images:
127+
```
128+
docker image ls
129+
```
130+
131+
Remove local image:
132+
```
133+
docker image rm <image_name_or_id>
134+
```
135+
136+
## Managing disk usage
137+
138+
See how much space is taken by docker:
139+
140+
```
141+
docker system df
142+
```
143+
144+
Cleaning unused data:
145+
146+
```
147+
docker system prune
148+
```
149+
150+
See [official documentation](https://docs.docker.com/engine/reference/commandline/system_prune/)
151+
for more info.
152+
153+
## Building a Docker Container from scratch
154+
155+
Docker containers can be built with the following command:
156+
157+
```
158+
docker build -f path/to/devops/containers/file.Dockerfile path/to/devops/
159+
```
160+
161+
The `ubuntu2004_preinstalled.Dockerfile` script expects `llvm_sycl.tar.xz` file
162+
to be present in `devops/` directory.
163+
164+
Containers other than base provide several configurable arguments, the most
165+
commonly used are `base_image` and `base_tag`, which specify the base Docker
166+
image and its tag. You can set additional arguments with `--build-arg ARG=value`
167+
argument.
168+

sycl/doc/index.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Data Parallel C++ Documentation
22
===============================
33

44
Using oneAPI DPC++ for Application Development
5-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
----------------------------------------------
66

77
.. toctree::
88
:maxdepth: 1
@@ -18,7 +18,7 @@ Using oneAPI DPC++ for Application Development
1818
EnvironmentVariables
1919

2020
Developing oneAPI DPC++ Compiler
21-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
--------------------------------
2222

2323
.. toctree::
2424
:maxdepth: 1
@@ -41,3 +41,9 @@ Developing oneAPI DPC++ Compiler
4141
SYCLInstrumentationUsingXPTI
4242
ITTAnnotations
4343

44+
Development BKMs
45+
~~~~~~~~~~~~~~~~
46+
47+
.. toctree::
48+
:maxdepth: 1
49+
dev/DockerBKMs

0 commit comments

Comments
 (0)