区块链技术博客
www.b2bchain.cn

Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)求职学习资料

本文介绍了Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

  • 介绍
  • 所需软件
  • 安装前
    • GCC
    • NVIDIA package repositories
  • NVIDIA machine learning
  • NVIDIA GPU driver
  • CUDA ToolKit and cuDNN
  • TensorRT
  • Miniconda
  • 虚拟环境
  • 安装 TensorFlow
  • 安装 JupyterLab 和 matplotlib
  • 在 JupyterLab 中运行 TensorFlow
  • 安装 VSCode
  • VSCode 运行 tensorflow
  • 小结
  • 参考链接

介绍

  • Ubuntu 18.04.5 LTS
  • GTX 1070
  • TensorFlow 2.4.1

所需软件

  • NVIDIA® GPU drivers —CUDA® 11.0 需要 450.x 或者更高版本。
  • CUDA® Toolkit — TensorFlow 所需 CUDA® 11 (TensorFlow >= 2.4.0)
  • cuDNN SDK 8.0.4 cuDNN versions。
  • _(Optional)_ TensorRT 6.0 改善延迟和吞吐量,以在某些模型上进行推理。
  • Miniconda — 创建虚拟环境。

安装前

GCC

$ gcc --version Command 'gcc' not found, but can be installed with: sudo apt install gcc $ sudo apt install gcc $ gcc --version gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

NVIDIA package repositories

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub $ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" $ sudo apt-get update

NVIDIA machine learning

$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb  $ sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb $ sudo apt-get update

NVIDIA GPU driver

$ sudo apt-get install --no-install-recommends nvidia-driver-460

注:这里需要使用 460 版本,TensorFlow 官网写的是 450,实测失败。

重启并使用以下命令检查 GPU 是否可见。

$ nvidia-smi Mon Apr  5 16:17:17 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     | |-------------------------------+----------------------+----------------------+ | 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  GeForce GTX 1070    On   | 00000000:01:00.0  On |                  N/A | |  0%   48C    P8     9W / 180W |    351MiB /  8111MiB |      1%      Default | |                               |                      |                  N/A | +-------------------------------+----------------------+----------------------+  +-----------------------------------------------------------------------------+ | Processes:                                                                  | |  GPU   GI   CI        PID   Type   Process name                  GPU Memory | |        ID   ID                                                   Usage      | |=============================================================================| |    0   N/A  N/A       997      G   /usr/lib/xorg/Xorg                 18MiB | |    0   N/A  N/A      1145      G   /usr/bin/gnome-shell               53MiB | |    0   N/A  N/A      1353      G   /usr/lib/xorg/Xorg                108MiB | |    0   N/A  N/A      1495      G   /usr/bin/gnome-shell               83MiB | |    0   N/A  N/A      1862      G   ...AAAAAAAAA= --shared-files       82MiB | +-----------------------------------------------------------------------------+

CUDA ToolKit and cuDNN

$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt-get update  # Install development and runtime libraries (~4GB) $ sudo apt-get install --no-install-recommends      cuda-11-0      libcudnn8=8.0.4.30-1+cuda11.0       libcudnn8-dev=8.0.4.30-1+cuda11.0

TensorRT

$ sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0      libnvinfer-dev=7.1.3-1+cuda11.0      libnvinfer-plugin7=7.1.3-1+cuda11.0

Miniconda

从 https://docs.conda.io/en/latest/miniconda.html 下载 Python 3.8 安装脚本。

Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)

增加可执行权限

$ chmod +x Miniconda3-latest-Linux-x86_64.sh

  • 介绍
  • 所需软件
  • 安装前
    • GCC
    • NVIDIA package repositories
  • NVIDIA machine learning
  • NVIDIA GPU driver
  • CUDA ToolKit and cuDNN
  • TensorRT
  • Miniconda
  • 虚拟环境
  • 安装 TensorFlow
  • 安装 JupyterLab 和 matplotlib
  • 在 JupyterLab 中运行 TensorFlow
  • 安装 VSCode
  • VSCode 运行 tensorflow
  • 小结
  • 参考链接

介绍

  • Ubuntu 18.04.5 LTS
  • GTX 1070
  • TensorFlow 2.4.1

所需软件

  • NVIDIA® GPU drivers —CUDA® 11.0 需要 450.x 或者更高版本。
  • CUDA® Toolkit — TensorFlow 所需 CUDA® 11 (TensorFlow >= 2.4.0)
  • cuDNN SDK 8.0.4 cuDNN versions。
  • _(Optional)_ TensorRT 6.0 改善延迟和吞吐量,以在某些模型上进行推理。
  • Miniconda — 创建虚拟环境。

安装前

GCC

$ gcc --version Command 'gcc' not found, but can be installed with: sudo apt install gcc $ sudo apt install gcc $ gcc --version gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

NVIDIA package repositories

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub $ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" $ sudo apt-get update

NVIDIA machine learning

$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb  $ sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb $ sudo apt-get update

NVIDIA GPU driver

$ sudo apt-get install --no-install-recommends nvidia-driver-460

注:这里需要使用 460 版本,TensorFlow 官网写的是 450,实测失败。

重启并使用以下命令检查 GPU 是否可见。

$ nvidia-smi Mon Apr  5 16:17:17 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     | |-------------------------------+----------------------+----------------------+ | 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  GeForce GTX 1070    On   | 00000000:01:00.0  On |                  N/A | |  0%   48C    P8     9W / 180W |    351MiB /  8111MiB |      1%      Default | |                               |                      |                  N/A | +-------------------------------+----------------------+----------------------+  +-----------------------------------------------------------------------------+ | Processes:                                                                  | |  GPU   GI   CI        PID   Type   Process name                  GPU Memory | |        ID   ID                                                   Usage      | |=============================================================================| |    0   N/A  N/A       997      G   /usr/lib/xorg/Xorg                 18MiB | |    0   N/A  N/A      1145      G   /usr/bin/gnome-shell               53MiB | |    0   N/A  N/A      1353      G   /usr/lib/xorg/Xorg                108MiB | |    0   N/A  N/A      1495      G   /usr/bin/gnome-shell               83MiB | |    0   N/A  N/A      1862      G   ...AAAAAAAAA= --shared-files       82MiB | +-----------------------------------------------------------------------------+

CUDA ToolKit and cuDNN

$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt-get update  # Install development and runtime libraries (~4GB) $ sudo apt-get install --no-install-recommends      cuda-11-0      libcudnn8=8.0.4.30-1+cuda11.0       libcudnn8-dev=8.0.4.30-1+cuda11.0

TensorRT

$ sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0      libnvinfer-dev=7.1.3-1+cuda11.0      libnvinfer-plugin7=7.1.3-1+cuda11.0

Miniconda

从 https://docs.conda.io/en/latest/miniconda.html 下载 Python 3.8 安装脚本。

Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)

增加可执行权限

$ chmod +x Miniconda3-latest-Linux-x86_64.sh

  • 介绍
  • 所需软件
  • 安装前
    • GCC
    • NVIDIA package repositories
  • NVIDIA machine learning
  • NVIDIA GPU driver
  • CUDA ToolKit and cuDNN
  • TensorRT
  • Miniconda
  • 虚拟环境
  • 安装 TensorFlow
  • 安装 JupyterLab 和 matplotlib
  • 在 JupyterLab 中运行 TensorFlow
  • 安装 VSCode
  • VSCode 运行 tensorflow
  • 小结
  • 参考链接

介绍

  • Ubuntu 18.04.5 LTS
  • GTX 1070
  • TensorFlow 2.4.1

所需软件

  • NVIDIA® GPU drivers —CUDA® 11.0 需要 450.x 或者更高版本。
  • CUDA® Toolkit — TensorFlow 所需 CUDA® 11 (TensorFlow >= 2.4.0)
  • cuDNN SDK 8.0.4 cuDNN versions。
  • _(Optional)_ TensorRT 6.0 改善延迟和吞吐量,以在某些模型上进行推理。
  • Miniconda — 创建虚拟环境。

安装前

GCC

$ gcc --version Command 'gcc' not found, but can be installed with: sudo apt install gcc $ sudo apt install gcc $ gcc --version gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

NVIDIA package repositories

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub $ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" $ sudo apt-get update

NVIDIA machine learning

$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb  $ sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb $ sudo apt-get update

NVIDIA GPU driver

$ sudo apt-get install --no-install-recommends nvidia-driver-460

注:这里需要使用 460 版本,TensorFlow 官网写的是 450,实测失败。

重启并使用以下命令检查 GPU 是否可见。

$ nvidia-smi Mon Apr  5 16:17:17 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     | |-------------------------------+----------------------+----------------------+ | 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  GeForce GTX 1070    On   | 00000000:01:00.0  On |                  N/A | |  0%   48C    P8     9W / 180W |    351MiB /  8111MiB |      1%      Default | |                               |                      |                  N/A | +-------------------------------+----------------------+----------------------+  +-----------------------------------------------------------------------------+ | Processes:                                                                  | |  GPU   GI   CI        PID   Type   Process name                  GPU Memory | |        ID   ID                                                   Usage      | |=============================================================================| |    0   N/A  N/A       997      G   /usr/lib/xorg/Xorg                 18MiB | |    0   N/A  N/A      1145      G   /usr/bin/gnome-shell               53MiB | |    0   N/A  N/A      1353      G   /usr/lib/xorg/Xorg                108MiB | |    0   N/A  N/A      1495      G   /usr/bin/gnome-shell               83MiB | |    0   N/A  N/A      1862      G   ...AAAAAAAAA= --shared-files       82MiB | +-----------------------------------------------------------------------------+

CUDA ToolKit and cuDNN

$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb $ sudo apt-get update  # Install development and runtime libraries (~4GB) $ sudo apt-get install --no-install-recommends      cuda-11-0      libcudnn8=8.0.4.30-1+cuda11.0       libcudnn8-dev=8.0.4.30-1+cuda11.0

TensorRT

$ sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0      libnvinfer-dev=7.1.3-1+cuda11.0      libnvinfer-plugin7=7.1.3-1+cuda11.0

Miniconda

从 https://docs.conda.io/en/latest/miniconda.html 下载 Python 3.8 安装脚本。

Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)

增加可执行权限

$ chmod +x Miniconda3-latest-Linux-x86_64.sh

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » Ubuntu 机器学习环境 (TensorFlow GPU, JupyterLab, VSCode)求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们