Skip to content

Commit 1c5b4a6

Browse files
committed
Docker Hub and README.md tweaking
1 parent e15f621 commit 1c5b4a6

4 files changed

Lines changed: 75 additions & 53 deletions

File tree

README.md

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,30 @@
22

33
Run commands or a shell, with only given GPU devices visible.
44

5-
This script uses a thin Docker container under the hood that exposes
6-
the host filesystem and OS inside the container, and restricts the
7-
available GPUs within the spawned shell environment to the ones you
8-
specify.
5+
`isolate-gpu` is a script that is useful when you have more than one
6+
GPU in your machine, and you want to restrict the access of
7+
applications to a subset of GPUs, aka isolating GPUs.
98

10-
This is useful when you have more than one GPU in your machine, and
11-
you want to restrict the access of applications to a subset of GPUs,
12-
aka isolating GPUs.
13-
14-
The ROCm documentation teaches you how to do that with Docker, see
15-
here:
16-
17-
https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/docker.html#docker-restrict-gpus
9+
The ROCm documentation teaches you how to do that with Docker,
10+
[here](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/docker.html#docker-restrict-gpus).
1811

1912
However, that leaves open the question of what OS to run within the
2013
container?
2114

22-
isolate-gpu answers that question with "none". Its container image is
23-
practically empty; it is mostly a wrapper around the host's
24-
filesystem. I.e., there is no separate distribution inside the
25-
container. The idea is to be able to work inside the container mostly
26-
as if you were outside.
15+
`isolate-gpu` answers that question with "none". It uses a thin
16+
Docker container under the hood that exposes the host filesystem and
17+
OS inside the container, and restricts the available GPUs within the
18+
spawned shell environment to the ones you specify.
19+
20+
The container image is practically empty; it is mostly a wrapper
21+
around the host's filesystem. I.e., there is no separate distribution
22+
inside the container. The idea is to be able to work inside the
23+
container mostly as if you were outside.
2724

2825
The non-user-data OS directories are mounted readonly within the
29-
container. That is, /usr/, /etc, /var/, etc. This is to avoid the
30-
possibility of the container corrupting the host. /home, /net, and
31-
/mnt, are mounted read-write.
26+
container. That is, `/usr/`, `/etc`, `/var/`, etc. This is to avoid
27+
the possibility of the container corrupting the host. `/home`,
28+
`/net`, and `/mnt`, are mounted read-write.
3229

3330
## Features
3431

@@ -48,58 +45,60 @@ possibility of the container corrupting the host. /home, /net, and
4845
- Can be run with arguments, which are passed as commands to the
4946
non-interative shell inside the container.
5047

51-
## Building the image
48+
## Installation
49+
50+
To install the `isolate-gpu` script, simply copy or symlink it to some
51+
directory found in your `$PATH`. E.g., you can download it directly
52+
from github, like so:
5253

5354
```bash
54-
git clone https://github.com/palves/isolate-gpu.git
55-
cd isolate-gpu
56-
./build-docker
55+
$ cd ~/bin
56+
$ wget https://raw.githubusercontent.com/palves/isolate-gpu/refs/heads/main/isolate-gpu
57+
$ chmod u+x isolate-gpu
5758
```
5859

59-
## Installation
60-
61-
This image is not meant to be run directly. Instead, there is a
62-
**isolate-gpu** helper script you use to enter the container
63-
environment and/or execute build commands on build directories that
64-
exist on the local host filesystem.
60+
When you run `isolate-gpu` for the first time, it downloads the Docker
61+
image from Docker Hub automatically, you don't need to build it
62+
yourself.
6563

66-
To install the helper script, simply copy or symlink it to some
67-
directory found in your \$PATH. E.g.:
64+
## Usage
6865

6966
```bash
70-
ln -s /path/to/isolate-gpu-git/isolate-gpu ~/bin/
67+
$ isolate-gpu [opts...] [command] [args...]
7168
```
7269

73-
## Examples
70+
If a command is not specified, then `isolate-gpu` spawns an
71+
interactive shell within the isolated environment. Exiting the shell
72+
exits the container.
7473

75-
1. `isolate-gpu --device 1`: Run an interactive shell inside the
76-
container, exposing GPU 1, preserving current directory.
74+
If a command is specified, then `isolate-gpu` executes the command
75+
inside the container, and exits the container when the command exits.
7776

78-
2. `isolate-gpu --device 1 make`: Invoke make with the *Makefile*
79-
found in the current directory.
77+
See `isolate-gpu --help` for more details.
8078

81-
## Usage
79+
## Examples
8280

83-
For example, here\'s how to run the ROCm-specific tests in GDB's
84-
testsuite, on GPU 1:
81+
1. Run an interactive shell inside the container, exposing GPU 1,
82+
preserving current directory:
8583

8684
```bash
87-
cd /path/to/gdb/build/gdb/
88-
isolate-gpu --device 1
89-
# You're now inside the container, in the same directory as you were.
90-
make check -j32 RUNTESTFLAGS="gdb.rocm/*.exp"
85+
$ isolate-gpu --device 1
9186
```
9287

93-
Alternatively, you can invoke any command inside the container by
94-
prepending the **isolate-gpu** script on the commandline. Assuming
95-
**isolate-gpu** can be found in your PATH, you can run:
88+
2. Invoke make with the *Makefile* found in the current directory:
9689

9790
```bash
98-
$ isolate-gpu [opts...] [command] [args...]
91+
$ isolate-gpu --device 1 make
9992
```
10093

101-
For example:
94+
## Rebuilding the image
95+
96+
This isn't normally needed, because the image is available on [docker
97+
hub](https://hub.docker.com/r/palves79/isolate-gpu), but if you want
98+
to, you can rebuild it with:
10299

103100
```bash
104-
$ isolate-gpu --device 1 make check -j32 RUNTESTFLAGS="gdb.rocm/*.exp"
101+
git clone https://github.com/palves/isolate-gpu.git
102+
cd isolate-gpu
103+
./build-docker
105104
```

build-docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# SPDX-License-Identifier: GPL-3.0-or-later
33
# Author : Pedro Alves (pedro@palves.net)
44

5-
docker build -t isolate-gpu .
5+
docker build -t palves79/isolate-gpu .

isolate-gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,4 @@ docker run --rm \
212212
-e ISOLATE_GPU_CWD="$(pwd)" \
213213
-h "$CONTAINER_HOSTNAME" \
214214
"${VOLS[@]}" \
215-
isolate-gpu "$@"
215+
palves79/isolate-gpu "$@"

push-docker-hub

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
VERSION=$(git describe --tags --abbrev=0)
6+
7+
# Check if the current commit is tagged with VERSION.
8+
CURRENT_COMMIT_TAG=$(git describe --tags --exact-match 2>/dev/null \
9+
|| echo "none")
10+
if [ "$CURRENT_COMMIT_TAG" != "$VERSION" ]; then
11+
echo "Error: The current commit is not tagged with the latest tag ($VERSION)."
12+
echo "Ensure you have checked out the commit matching the latest tag."
13+
exit 1
14+
fi
15+
16+
./build-docker
17+
18+
# Tag and push with the specific version.
19+
docker tag palves79/isolate-gpu palves79/isolate-gpu:$VERSION
20+
docker push palves79/isolate-gpu:$VERSION
21+
22+
# Push the "latest" tag.
23+
docker push palves79/isolate-gpu:latest

0 commit comments

Comments
 (0)