GPU memory can be shared among various Docker containers by using NVIDIA Container Toolkit.
First, you need to install NVIDIA Container Toolkit on your host machine. You can follow the instructions mentioned in the official documentation to install it.
Once installed, you need to create a docker-compose file for your containers. In the docker-compose file, you need to specify the runtime as nvidia and the devices as /dev/nvidia0:/dev/nvidia0. This will enable the container to use the GPU.
In the Dockerfile of each container, you can set the environment variable NVIDIAVISIBLEDEVICES to the list of GPUs that the container needs access to.
You can then run the containers using the docker-compose command, and each container will have access to the specified GPUs.
Example docker-compose file:
version: '3'
services:
gpu-container-1:
build: ./gpu-container-1
runtime: nvidia
devices:
- /dev/nvidia0:/dev/nvidia0
environment:
- NVIDIA_VISIBLE_DEVICES=0,1
gpu-container-2:
build: ./gpu-container-2
runtime: nvidia
devices:
- /dev/nvidia0:/dev/nvidia0
environment:
- NVIDIA_VISIBLE_DEVICES=2
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-08-17 11:00:00 +0000
Seen: 20 times
Last updated: Jan 21 '23
How can I eliminate a network that has been deleted from a Docker container?
Is it not possible to use composer with Docker container when using Laravel Sail?
How can I upload a docker container on a Cent Os 7 Linux server?
What are the steps for activating GitLab Container Registry and uploading docker image to it?
How can the issue "host not found in upstream" be resolved in Docker Networking with nginx?
How can I display a progress bar for GNU Parallel in a Docker container?
What is the method for adding an icon to the lower right corner of a container in Flutter?