简体   繁体   中英

How do I use docker-compose.yml with Tensorflow + Jupyter Notebook + GPU

I've been using tensorflow docker images to run Tensorflow with GPU which works fine. For example, I just write this command with the --gpus all flag.

docker run -it --rm --gpus all -v $PWD:/tf/notebooks -p 8888:8888 tensorflow/tensorflow:2.2.2-gpu-py3-jupyter

I would like to use docker-compose instead and was trying to follow the steps from Docker's enabling GPU access site docker website and can't get it to work with the jupyter notebook GPU Tensorflow images. Anybody know what I'm doing wrong?

Below is my docker-compose.yml code which I use to run the command docker-compose up

#version: "3.3"

services:
  jupyter:  # you can change this to whatever you want.
    container_name: computer-vison
    image: tensorflow/tensorflow:2.2.2-gpu-py3-jupyter
    volumes:
      - "./:/tf/notebooks"
    ports:
     - "8888:8888"
    deploy:
      resources:
        reservations:
          devices:
          -  driver: nvidia
            count: all
            capabilities: [gpu]

The error I get is

ERROR: yaml.parser.ParserError: while parsing a block mapping
  in "./docker-compose.yaml", line 14, column 11
expected <block end>, but found '<block mapping start>'
  in "./docker-compose.yaml", line 16, column 13

It seems like an indentation error at the line with count , try this:


#version: "3.3"

services:
  jupyter:  # you can change this to whatever you want.
    container_name: computer-vison
    image: tensorflow/tensorflow:2.2.2-gpu-py3-jupyter
    volumes:
      - "./:/tf/notebooks"
    ports:
     - "8888:8888"
    deploy:
      resources:
        reservations:
          devices:
          -  driver: nvidia
             count: all
             capabilities: [gpu]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM