Skip to content

Commit e4e5ed3

Browse files
nnethercoteLegNeato
authored andcommitted
Overhaul "Getting started" in the Guide.
I've rewritten the entire thing. A lot of the details that were present are still there, but there is also: - a complete example with all the code and the file structure; - more detail in a bunch of places; - a couple of useful scripts I've been using with Docker; - more useful and correct instructions for using Docker.
1 parent 94c28c8 commit e4e5ed3

File tree

3 files changed

+323
-170
lines changed

3 files changed

+323
-170
lines changed

container/scripts/dcr

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#! /bin/sh
2+
#----------------------------------------------------------------------------
3+
# Create a rust-cuda Docker container that will persist until explicitly
4+
# stopped, even if the host machine is rebooted.
5+
#
6+
# Useful docker commands:
7+
# - `docker ps` shows details about the running container.
8+
# - `docker stop rust-cuda` stops the running container, and `docker rm
9+
# rust-cuda` deletes the running container. This is only necessary if you
10+
# have no more use for the container.
11+
# - `docker exec -it rust-cuda bash` starts a bash shell within the container.
12+
#
13+
# Operations within the container can be performed from outside the container
14+
# with the accompanying `dex` script, e.g. `./dex cargo build`. This may be
15+
# easier than using a shell within the container, because the packages
16+
# available within the container are limited.
17+
#
18+
# Because the container name is hard-wired as `rust-cuda`, as written this
19+
# script can only work with one container at a time.
20+
#----------------------------------------------------------------------------
21+
22+
# Explanation
23+
# - `--restart`/`sleep infinity` keeps it running (including restarting as
24+
# necessary, e.g. after a reboot) until explicitly stopped.
25+
# - The `-e`/`-v` options for cargo and rustup means files downloaded by those
26+
# programs will persist when the container is restarted.
27+
# - The `-v`/`-w` for the workspace mean the current directory will be the
28+
# workspace, i.e. the files visible within the container.
29+
docker create \
30+
--name rust-cuda \
31+
--restart unless-stopped \
32+
--entrypoint "" \
33+
--gpus all \
34+
-e CARGO_HOME=/cargo \
35+
-v rust-cuda-cargo:/cargo \
36+
-e RUSTUP_HOME=/rustup \
37+
-v rust-cuda-rustup:/rustup \
38+
-v "$PWD":/workspace \
39+
-w /workspace \
40+
ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:main \
41+
sleep infinity
42+
43+
docker start "$CONTAINER_NAME"

container/scripts/dex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/sh
2+
#----------------------------------------------------------------------------
3+
# Execute a command within a rust-cuda Docker container created with the
4+
# accompanying `dcr` script.
5+
#
6+
# E.g. `./dex cargo build` runs `cargo build` within the container.
7+
#----------------------------------------------------------------------------
8+
9+
docker exec rust-cuda bash -lc "$*"

0 commit comments

Comments
 (0)