Search code examples
dockerpowershelldockerfile

Launching Docker with GPU Usage and JupyterNotebook


I am building a Dockfile and I used this as the file contents:

FROM ubuntu:20.04
FROM python:3.10.13
FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime
WORKDIR /
COPY . .

RUN apt update
RUN apt install -y git
RUN pip install jupyter
RUN pip install transformers

EXPOSE 8888

ENV NAME World

CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"]

I am using Windows 11 and Windows Subsystem for Linux (WSL). I used this command to create the Docker Image:

docker build -t nlp_python:latest .

When I didn't include --gpus all it did not run with the GPU when I tested it in the Jupyter Notebook so then I ran the following command:

What worked

docker run --gpus all -it -p 8888:8888 nlp_python:latest

My Question

Does what worked create a new container each time or is there a modification of that command that I can use the container that it previously created called gracious_feistel?

I am expecting to use to the same container each time that I run the command through PowerShell. What resulted from this command was it created a new container which I am trying to avoid.


Solution

  • There's docker start, see 'How restart a stopped docker container' for the options of the command along the lines of docker start container_name.