You need a CUDA-capable GPU with suitable drivers installed
Install NVIDIA Container Toolkit
Build the Docker Image¶
To use anomalib with Docker, you can build a Docker image containing anomalib all its dependencies from the provided Dockerfile. To this end, navigate to the anomalib root directory (the one containing the Dockerfile) and build the Docker image with
docker build . --tag=anomalib
Run the Docker Image¶
After building the image, you can run it as follows
docker run \ -it --rm \ --ipc=host \ --env="DISPLAY" \ --gpus=all \ -w /anomalib \ -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ -v "$(pwd)":/anomalib \ anomalib \ /bin/bash
This creates an interactive bash session inside the Docker container, in which you can run all anomalib commands as described in the readme.
The source code is mapped into the running container by means of the -v “$(pwd)”:/anomalib parameter. This facilitates changes to the source code without having to rebuild the Docker image.
To forward graphical output of the Docker container to the host operating system, you have to disable access control of the host’s X11 server. To this end, execute the shell command xhost + on the host.
You may also use the Remote-Containers extension for VSCode for deployment with Docker, which can be set up as follows:
Install and run VSCode
Install the Remote-Containers extension by Microsoft in VSCode.
Open command panel by pressing
CTRL + SHIFT + P.
Remote-Containers: Open Folder in Containerand press Enter.
Navigate to the root of anomalib folder. (The one with Dockerfile).
Give it time to build the image and install the extensions. Grab a ☕ as this will take a while for the first time as the container needs to be built.
And voilà 🎊 you should now see your folder mounted in the docker container and begin developing. Your changes should automatically be reflected in your host directory.
If VSCode throws an error regarding not having sufficient privileges, try restarting the system.