admin 管理员组文章数量: 887016
摘要
-
不要安装 Docker Desktop!我们将在 Ubuntu 中自行安装 Docker。
-
请安装 Windows 10 Insider Build 或 Windows 11 (Beta也行)。(稳定发行版无法在 WSL 2 中使用 GPU)
-
请安装 WSL 2 w/Ubuntu 20.04 或同等版本。
-
请安装 Nvidia CUDA 软件包(不是 Cuda Toolkit)。
-
请在 WSL2/Ubuntu 中手动安装 Docker。
-
请在 WSL2/Ubuntu 中安装 Nvidia Container Toolkit。
-
使用 Tensorflow 运行 N 体模拟 CUDA 示例、Jupyter。
4 安装 Nvidia CUDA 软件包(不是 Cuda Toolkit)
Nvidia 建议使用 Linux 包管理器在 WSL 2 下安装 CUDA(而不是 CUDA Toolkit)。这是因为 CUDA Toolkit 附带了 Nvidia 的 Linux GPU 驱动程序,该驱动程序不得安装在 WSL 2 下。
wget https://developer.download.nvidia/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia/compute/cuda/11.4.0/local_installers/cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
运行 CUDA 应用程序
测试:构建并运行 BlackScholes 示例应用程序:
cd /usr/local/cuda-11.4/samples/4_Finance/BlackScholes
then:
sudo make BlackScholes
then:
./BlackScholes
[./BlackScholes] - Starting...
GPU Device 0: "Ampere" with compute capability 8.6
Initializing data...
...allocating CPU memory for options.
...allocating GPU memory for options.
...generating input data in CPU mem.
...copying input data to GPU mem.
Data init done.
Executing Black-Scholes GPU kernel (512 iterations)...
Options count : 8000000
BlackScholesGPU() time : 0.125945 msec
Effective memory bandwidth: 635.196316 GB/s
Gigaoptions per second : 63.519632
BlackScholes, Throughput = 63.5196 GOptions/s, Time = 0.00013 s, Size = 8000000 options, NumDevsUsed = 1, Workgroup = 128
Reading back GPU results...
Checking the results...
...running CPU calculations.
Comparing the results...
L1 norm: 1.741792E-07
Max absolute error: 1.192093E-05
Shutting down...
...releasing GPU memory.
...releasing CPU memory.
Shutdown done.
[BlackScholes] - Test Summary
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.
Test passed
6.安装Docker
在 bash shell 中,使用以下 Docker 安装脚本来安装 Docker:
curl https://get.docker | sh
然后,确保 Docker 处于活动状态:
docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker/
For more examples and ideas, visit:
https://docs.docker/get-started/
7.Nvidia容器工具包
这里的说明是 Ubuntu 的提供程序(单独运行每个命令):
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
curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
然后,在另一个 WSL 2 窗口中,停止并重新启动 docker 守护进程,如下所示:
sudo service docker stop && sudo service docker start
资源
https://github/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#is-microsoft-windows-supported
https://docs.nvidia/datacenter/cloud-native/container-toolkit/latest/index.html
https://github/NVIDIA/nvidia-docker/issues/665
https://developer.nvidia/cuda/wsl
本文标签: 深度 环境 Windows Nvidia docker
版权声明:本文标题:【一次性解决深度学习环境】windows安装 NVIDIA Docker 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1729682816h1339034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论