In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to use Docker to quickly deploy the GPU environment", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to quickly deploy the GPU environment with Docker" this article.
It is normal to run a deep learning model using GPU on a Linux server. If we want to implement the same requirements with Docker, we need to do some extra work. In essence, we should be able to see and use the video card on the host in the container. In this article we will introduce the environment in which Docker is built using GPU.
Nvidia driver
Some commands use Ubuntu as an example. First of all, Nvidia drivers must be installed on the host machine.
It is recommended to download the script from the Nvidia official website to install, install and uninstall it and is suitable for any Linux distribution, including CentOS,Ubuntu, etc. The Linux driver of NVIDIA Telsa GPU needs to compile kernel module during the installation process, and the system needs to install gcc in advance and compile the packages that Linux Kernel Module depends on, such as kernel-devel-$ (uname-r) and so on.
Install gcc and kernel-dev
$sudo apt install gcc kernel-dev-y
Install the Nvidia driver
Visit https://www.nvidia.com/Download/Find.aspx
Select the corresponding operating system and installation package, and click [SEARCH] to search for the driver and select the version of the driver to download.
3. Download and execute the corresponding version of the installation script on the host
$wget https://www.nvidia.com/content/DriverDownload-March3009/confirmation.php?url=/tesla/450.80.02/NVIDIA-Linux-x86_64-450.80.02.run&lang=us&type=Tesla $chmod + x NVIDIA-Linux-x86_64-450.80.02.run & &. / NVIDIA-Linux-x86_64-450.80.02.run
4. Verification
Use the nvidia-smi command to verify that the installation is successful, and if the output is similar to the following figure, the driver is installed successfully.
CUDA driver
CUDA (Compute Unified Device Architecture) is a computing platform launched by NVIDIA, a graphics card manufacturer. CUDA ™is a general parallel computing architecture introduced by NVIDIA, which enables GPU to solve complex computing problems. It includes the CUDA instruction set architecture (ISA) and the parallel computing engine within GPU. The installation here is similar to the installation of the video card driver.
1. Visit the official website to download the corresponding version of the installation package, https://developer.nvidia.com/cuda-toolkit-archive
two。 Configure environment variables
$echo 'export PATH=/usr/local/cuda/bin:$PATH' | sudo tee / etc/profile.d/cuda.sh $source / etc/profile
Nvidia-docker2
The installation of Docker will not be expanded here, and the details of the official documentation are very detailed.
Here we will directly introduce the installation of nvidia-docker2.
Since it is called nvidia-docker2, there is nvidia-docker1, which is version 1.0, which is now obsolete, so be careful not to install it incorrectly.
First of all, let's briefly talk about the principle of nvidia-docker2. Nvidia-docker2 's dependency consists of the following parts.
Libnvidia-container
Nvidia-container-toolkit
Nvidia-container-runtime
Nvidia-container-runtime implements nvidia-container-runime-hook (now called nvidia-container-toolkit) on the basis of runc. The hook is executed after the container is started (Namespace has been created) and before the container custom command (Entrypoint) is started. When the NVIDIA_VISIBLE_DEVICES environment variable is detected, libnvidia-container is called to mount GPU Device and CUDA Driver. If no NVIDIA_VISIBLE_DEVICES is detected, the default runc is executed.
The installation is divided into two steps
1. Set up repository and GPG key
$distribution=$ (. / etc/os-release;echo $ID$VERSION_ID) $curl-s-L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add-$curl-s-L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee / etc/apt/sources.list.d/nvidia-docker.list
two。 Installation
$sudo apt-get update $sudo apt-get install-y nvidia-docker2 $sudo systemctl restart docker
3. Verification
Execute the following command:
$docker run-rm-gpus all nvidia/cuda:10.2-base nvidia-smi
If the output is consistent with executing nvidia-smi directly on the host machine, the installation is successful. If the running deep learning model uses tensorflow, it can be executed in the container:
Import tensorflow as tf tf.contrib.eager.num_gpus ()
If you output the number of Nvidia video cards on the host, the model can use video card acceleration. If you are using pytorch, you can execute it in the container:
Import torch torch.cuda.is_available ()
If the output True proves that the environment is also successful, you can use a video card.
4. Use the example
Use all video cards
$docker run-- rm-- gpus all nvidia/cuda nvidia-smi $docker run-- rm-- runtime=nvidia-e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda nvidia-smi
Indicate which cards to use
$docker run-- gpus'"device=1,2"nvidia/cuda nvidia-smi $docker run-- rm-- runtime=nvidia-e NVIDIA_VISIBLE_DEVICES=1,2 nvidia/cuda nvidia-smi is all the contents of the article" how to quickly deploy a GPU environment with Docker ". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.