Detailed explanation of the process of using GPU in Docker

Detailed explanation of the process of using GPU in Docker

Take TensorFlow 2.0 as an example

Download tf-gpu

Select the tf version you want to download in docker hub ( note that you should select the one with GPU and py3 )

https://hub.docker.com/r/tensorflow/tensorflow/

insert image description here

like:

docker pull tensorflow/tensorflow:2.0.3-gpu-py3

If the above download times out, you can configure the Tsinghua source.
Or download it using the following command:

docker pull docker.mirrors.ustc.edu.cn/tensorflow/tensorflow:2.0.3-gpu-py3

Build your own image based on the pulled tf-gpu image

The following dockerfile

FROM docker.mirrors.ustc.edu.cn/tensorflow/tensorflow:2.0.3-gpu-py3

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone && \
	pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy pandas sklearn scipy matplotlib seaborn pyyaml ​​h5py hdfs

RUN pip install deepctr[gpu] -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
RUN pip install keras==2.3.1 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com


# cd /data/wangguisen/ad_ctr
# docker build -t tf-deepctr:1.0 -f ./dk/Dockerfile_base .

Start the image to check whether the GPU is available

docker run --gpus '"device=0"' \
  --rm -it --name ad_ctr \
  -v /data/wangguisen/ad_ctr:/data/ad_ctr \
  tf-deepctr:1.0

Enter nvidia-smi If information about graphics card 0 appears, it means success.

insert image description here

References:

https://blog.csdn.net/weixin_35725559/article/details/112268434

https://zhuanlan.zhihu.com/p/83691871

This is the end of this article about the detailed explanation of how Docker uses GPU. For more information about how Docker uses GPU, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker container uses GPU method to implement

<<:  HTML head tag detailed introduction

>>:  Mobile browser Viewport parameters (web front-end design)

Recommend

Detailed installation and use tutorial of mysql 8.0.15 under windows

This article shares with you the detailed install...

Implementation of Linux command line wildcards and escape characters

If we want to perform batch operations on a type ...

A case study on MySQL optimization

1. Background A sql-killer process is set up on e...

Native JS to implement click number game

Native JS implements the click number game for yo...

Detailed introduction to nobody user and nologin in Unix/Linux system

What is the nobody user in Unix/Linux systems? 1....

Solution to the MySQL server has gone away error

MySQL server has gone away issue in PHP 1. Backgr...

JavaScript implements the protocol example in which the user must check the box

In js, set the user to read a certain agreement b...

JavaScript to achieve calendar effect

This article shares the specific code for JavaScr...

How to use boost.python to call c++ dynamic library in linux

Preface Recently I started using robot framework ...

React's context and props explained

Table of contents 1. context 1. Usage scenarios 2...

How to install and configure SSH service in Ubuntu 18.04

Install ssh tool 1. Open the terminal and type th...

JavaScript implements bidirectional linked list process analysis

Table of contents 1. What is a doubly linked list...