justadev
justadev

Reputation: 1496

Dockerfile for GPU and non-GPU versions

I have a project that I maintain using Dockerfile. It is a data science project so and the docker can be used in many environments, local, in the cloud, with or without GPU.

The difference between the GPU and the non-GPU version is very small, just this:

FROM ubuntu:18.04  -> non-GPU
FROM nvidia/cuda   -> GPU 

What is the best way to handle this scenario?

P.S: I am using docker-compose to build the docker

Upvotes: 0

Views: 417

Answers (1)

Sreedhar S
Sreedhar S

Reputation: 739

You can use multiple docker files inside your docker-compose yml file as below,

├── docker-compose.yml
├── GPU project
│   └── GPU.Dockerfile
└── NON-GPU project
    └── NONGPU.Dockerfile

Also it's possible to get syntax highlighting in VS code by giving files .Dockerfile extension(instead of name) e.g. GPU.Dockerfile, NONGPU.Dockerfile etc.

Upvotes: 2

Related Questions