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 explanation of Nginx static file service configuration and optimization

Root directory and index file The root directive ...

MySql 5.7.21 free installation version configuration method under win10

1. Unzip to the location where you want to instal...

JavaScript exquisite snake implementation process

Table of contents 1. Create HTML structure 2. Cre...

Implementation of Docker container connection and communication

Port mapping is not the only way to connect Docke...

javascript to switch by clicking on the picture

Clicking to switch pictures is very common in lif...

HTML input file control limits the type of uploaded files

Add an input file HTML control to the web page: &...

Implementation of webpack code fragmentation

Table of contents background CommonsChunkPlugin s...

Solution to the problem that VC6.0 cannot be used when installed on WIN10

VC6.0 is indeed too old VC6.0 is a development to...

Solution to the garbled problem of web pages when the encoding is set to utf-8

Recently, when I was writing web pages with PHP, I...

What are the rules for context in JavaScript functions?

Table of contents 1. Rule 1: Object.Method() 1.1 ...

Detailed explanation of Vue configuration request multiple server solutions

1. Solution 1.1 Describing the interface context-...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

WeChat applet implementation anchor positioning function example

Preface In the development of small programs, we ...