https://zh-v2.d2l.ai/chapter_installation/index.html
https://github.com/d2l-ai/d2l-zh-pytorch-slides

part-0_3.pdf

AWS

https://aws.amazon.com/cn/

  1. conda env remove d2l-zh
  2. conda create -n -y d2l-zh python=3.8 pip
  3. conda activate d2l-zh
  1. pip install jupyter d2l torch torchvision
  1. wget https://zh-v2.d2l.ai/d2l-zh.zip
  2. unzip d2l-zh.zip
  3. jupyter notebook

本地配置

https://www.zhihu.com/zvideo/1363284223420436480
https://developer.nvidia.com/cuda-downloads

Windows

  • 安装CUDA

Docker

  1. {
  2. "builder": {
  3. "gc": {
  4. "defaultKeepStorage": "20GB",
  5. "enabled": true
  6. }
  7. },
  8. "debug": false,
  9. "experimental": false,
  10. "features": {
  11. "buildkit": true
  12. },
  13. "insecure-registries": [],
  14. "registry-mirrors": ["http://hub-mirror.c.163.com"]
  15. }

参考

  • 怎么在docker中使用nvidia显卡

    1. docker run -itd --gpus all --name 容器名 -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all 镜像名
    1. docker run -itd --gpus all --name dl2 -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all ubuntu:20.04

    关键是参数

  • --gpus

  • NVIDIA_DRIVER_CAPABILITIES=compute,utility ```shell

    nvidia-smi

    Mon Feb 7 14:43:16 2022 +——————————————————————————————————————-+ | NVIDIA-SMI 495.47 Driver Version: 496.74 CUDA Version: 11.5 | |———————————————-+———————————+———————————+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce … On | 00000000:07:00.0 On | N/A | | 48% 33C P0 30W / 130W | 1255MiB / 6144MiB | N/A Default | | | | N/A | +———————————————-+———————————+———————————+

+——————————————————————————————————————-+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | No running processes found | +——————————————————————————————————————-+

  1. ```shell
  2. apt-get -y update upgrade
  3. apt-get -y install python3 python3-pip

需要配置ubuntu的国内源

  1. pip install jupyter d2l torch torchvision rise -i https://pypi.tuna.tsinghua.edu.cn/simple
  1. root@5bca661213be:/# python3
  2. Python 3.8.10 (default, Nov 26 2021, 20:14:08)
  3. [GCC 9.3.0] on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import torch
  6. >>> torch.cuda.is_available()
  7. True

启动jupyter

  1. root@5bca661213be:/home/d2l/03# jupyter notebook --allow-root
  2. [I 15:35:38.016 NotebookApp] Serving notebooks from local directory: /home/d2l/03
  3. [I 15:35:38.016 NotebookApp] Jupyter Notebook 6.4.8 is running at:
  4. [I 15:35:38.017 NotebookApp] http://localhost:8888/?token=30f1ec99ba77dbcc2bcc97b7825f839f205f3a731625442c
  5. [I 15:35:38.017 NotebookApp] or http://127.0.0.1:8888/?token=30f1ec99ba77dbcc2bcc97b7825f839f205f3a731625442c
  6. [I 15:35:38.017 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
  7. [W 15:35:38.019 NotebookApp] No web browser found: could not locate runnable browser.
  8. [C 15:35:38.019 NotebookApp]
  9. To access the notebook, open this file in a browser:
  10. file:///root/.local/share/jupyter/runtime/nbserver-5067-open.html
  11. Or copy and paste one of these URLs:
  12. http://localhost:8888/?token=30f1ec99ba77dbcc2bcc97b7825f839f205f3a731625442c
  13. or http://127.0.0.1:8888/?token=30f1ec99ba77dbcc2bcc97b7825f839f205f3a731625442c

发现打不开http://localhost:8888/?token=30f1ec99ba77dbcc2bcc97b7825f839f205f3a731625442c

参考

  • https://blog.csdn.net/weixin_40008349/article/details/81135847
  • https://www.jianshu.com/p/7797c3fe046e
    1. docker run -itd --gpus all -p 7777:8888 --name d2l -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all ubuntu:20.04
    1. root@3f1a0d12b531:/# python
    2. bash: python: command not found
    3. root@3f1a0d12b531:/# python3
    4. Python 3.8.10 (default, Nov 26 2021, 20:14:08)
    5. [GCC 9.3.0] on linux
    6. Type "help", "copyright", "credits" or "license" for more information.
    7. >>> from notebook.auth import passwd
    8. >>> passwd()
    9. Enter password:
    10. Verify password:
    11. 'argon2:$argon2id$v=19$m=10240,t=10,p=8$+uwc8JXm1uAfBkwhE5SewQ$QtpqRRD3ZUZ34QsBeyjp3+TSAU0m6ZB+c3vZ9+qn674'
    1. jupyter notebook --generate-config
    会生成jupyter_notebook_config.py
    1. c.NotebookApp.ip='*'
    2. c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$+uwc8JXm1uAfBkwhE5SewQ$QtpqRRD3ZUZ34QsBeyjp3+TSAU0m6ZB+c3vZ9+qn674'
    3. c.NotebookApp.open_browser = False
    4. c.NotebookApp.port =8888
    1. root@3f1a0d12b531:/home/d2l# jupyter notebook --allow-root
    2. [W 16:47:00.255 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
    3. [I 16:47:00.257 NotebookApp] Serving notebooks from local directory: /home/d2l
    4. [I 16:47:00.257 NotebookApp] Jupyter Notebook 6.4.8 is running at:
    5. [I 16:47:00.257 NotebookApp] http://3f1a0d12b531:8888/
    6. [I 16:47:00.257 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    7. [I 16:47:19.664 NotebookApp] Writing notebook-signing key to /root/.local/share/jupyter/notebook_secret
    8. [W 16:47:19.665 NotebookApp] Notebook d2l-zh-pytorch-slides/chapter_linear-networks/linear-regression-scratch.ipynb is not trusted
    9. [I 16:47:19.924 NotebookApp] Kernel started: 6c0939a7-2cae-4b47-8bf3-d24bcaa6a2ce, name: python3
    image.png
    image01.png
    image.png
    幻灯片模式
    image.png