Skip to content

Commit

Permalink
Improve docker instructions
Browse files Browse the repository at this point in the history
Fixes #68

Co-authored-by: Hilmar Lapp <[email protected]>
  • Loading branch information
johnbradley and hlapp committed Dec 5, 2024
1 parent 0fda236 commit 9183bc9
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,48 @@

A docker container for pybioclip is hosted at [ghcr.io](https://github.com/Imageomics/pybioclip/pkgs/container/pybioclip).
This container has CPU support for Mac, Windows, and Linux. GPU(CUDA) support is only for Windows and Linux.
In order to access your images the docker container requires you to [mount a volume](https://docs.docker.com/engine/storage/volumes). To avoid redownloading various bioclip files mounting a volume to hold a `.cache` directory is recommended. By default the working and home directories for this container are both set to `/home/bcuser`.

All examples below require an image file named [Ursus-arctos.jpeg](https://huggingface.co/spaces/imageomics/bioclip-demo/blob/main/examples/Ursus-arctos.jpeg) in the current directory.
### Volumes
In order to access files the docker container requires you to [mount a volume](https://docs.docker.com/engine/storage/volumes).
The working and home directories in this container are both set to `/home/bcuser`.
Minimally you need to mount a volume into this directory so pybioclip can read your images.
When running pybioclip the software will download various BioCLIP files into a `/home/bcuser/.cache` subdirectory. If you want to store the `.cache` folder in your home directory you will need to mount that directory (`~/.cache`) into the container at `/home/bcuser/.cache`.

### Setup
The examples below require an image file named [Ursus-arctos.jpeg](https://huggingface.co/spaces/imageomics/bioclip-demo/blob/ef075807a55687b320427196ac1662b9383f988f/examples/Ursus-arctos.jpeg) in the current directory.

## Mac/Linux CPU Usage
The following command will create predictions for the `Ursus-arctos.jpeg` image in the current directory.
The command mounts the current directory into the container at `/home/bcuser`.
The command mounts the `~/.cache` directory into the container to cache BioCLIP files in your home directory.
```console
docker run --platform linux/amd64 -v $(pwd):/home/bcuser -it ghcr.io/imageomics/pybioclip:1.0.0 bioclip predict Ursus-arctos.jpeg
docker run --platform linux/amd64 \
-v $(pwd):/home/bcuser \
-v ~/.cache:/home/bcuser/.cache \
--rm ghcr.io/imageomics/pybioclip:1.1.0 \
bioclip predict Ursus-arctos.jpeg
```

## Linux GPU Usage
The following command will create predictions using a GPU for the `Ursus-arctos.jpeg` image in the current directory.
```console
docker run --gpus all --platform linux/amd64 -v $(pwd):/home/bcuser -it ghcr.io/imageomics/pybioclip:1.0.0 bioclip predict --device cuda Ursus-arctos.jpeg
docker run --gpus all \
--platform linux/amd64 \
-v $(pwd):/home/bcuser \
-v ~/.cache:/home/bcuser/.cache \
--rm ghcr.io/imageomics/pybioclip:1.1.0 \
bioclip predict --device cuda Ursus-arctos.jpeg
```

## Windows CPU Usage

The following command will create predictions for the `Ursus-arctos.jpeg` image in the current directory.
Since this command does not mount `/home/bcuser/.cache` in the container the `.cache` directory will be created within the current directory.
```console
docker run -it -v %cd%:/home/bcuser ghcr.io/imageomics/pybioclip:1.0.0 bioclip predict Ursus-arctos.jpeg
docker run --rm -v %cd%:/home/bcuser ghcr.io/imageomics/pybioclip:1.0.0 bioclip predict Ursus-arctos.jpeg
```

## Windows GPU Usage

The following command will create predictions using a GPU for the `Ursus-arctos.jpeg` image in the current directory.
```console
docker run -it --gpus all -v %cd%:/home/bcuser ghcr.io/imageomics/pybioclip bioclip:1.0.0 predict --device cuda Ursus-arctos.jpeg
docker run --rm --gpus all -v %cd%:/home/bcuser ghcr.io/imageomics/pybioclip bioclip:1.0.0 predict --device cuda Ursus-arctos.jpeg
```

0 comments on commit 9183bc9

Please sign in to comment.