Skip to content

Commit b9ef977

Browse files
committed
Add a Dockerfile and document usage in README
1 parent 23ed990 commit b9ef977

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

Dockerfile.cpu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM tensorflow/tensorflow:1.12.0-py3
2+
3+
ENV LANG=C.UTF-8
4+
RUN mkdir /gpt-2
5+
WORKDIR /gpt-2
6+
COPY requirements.txt download_model.sh /gpt-2/
7+
RUN apt-get update && \
8+
apt-get install -y curl && \
9+
sh download_model.sh 117M
10+
RUN pip3 install -r requirements.txt
11+
12+
ADD . /gpt-2

Dockerfile.gpu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM tensorflow/tensorflow:1.12.0-gpu-py3
2+
3+
# nvidia-docker 1.0
4+
LABEL com.nvidia.volumes.needed="nvidia_driver"
5+
LABEL com.nvidia.cuda.version="${CUDA_VERSION}"
6+
7+
# nvidia-container-runtime
8+
ENV NVIDIA_VISIBLE_DEVICES=all \
9+
NVIDIA_DRIVER_CAPABILITIES=compute,utility \
10+
NVIDIA_REQUIRE_CUDA="cuda>=8.0" \
11+
LANG=C.UTF-8
12+
13+
RUN mkdir /gpt-2
14+
WORKDIR /gpt-2
15+
COPY requirements.txt download_model.sh /gpt-2/
16+
RUN apt-get update && \
17+
apt-get install -y curl && \
18+
sh download_model.sh 117M
19+
RUN pip3 install -r requirements.txt
20+
21+
ADD . /gpt-2

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ Install other python packages:
3434
pip3 install -r requirements.txt
3535
```
3636

37+
## Docker Installation
38+
39+
Build the Dockerfile and tag the created image as `gpt-2`:
40+
```
41+
docker build --tag gpt-2 -f Dockerfile.gpu . # or Dockerfile.cpu
42+
```
43+
44+
Start an interactive bash session from the `gpt-2` docker image.
45+
46+
You can opt to use the `--runtime=nvidia` flag if you have access to a NVIDIA GPU
47+
and a valid install of [nvidia-docker 2.0](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)).
48+
```
49+
docker run --runtime=nvidia -it gpt-2 bash
50+
```
51+
3752
## Usage
3853

3954
| WARNING: Samples are unfiltered and may contain offensive content. |

0 commit comments

Comments
 (0)