PyTorch快速安装-基于JupyterHub并运行K8s

PyTorch快速安装-基于JupyterHub并运行K8s

运行PyTorch能够直接逻辑运行、容器中运行、KubeFlow中运行以及基于JupyterHub(独立运行或运行在K8s之上)等多种模式。这里介绍运行在K8s上基于JupyterHub的PyTorch方法,这也是运行在云计算环境的推荐方法。若是须要使用GPU,则须要安装NVidia或AMD的Kubernetes下容器GPU支持,宿主机也必须同时安装GPU驱动。git

安装 kubernetes 的支持

安装 JupyterHub/JupyterLab支持

conda install numpy
conda install scikit-image

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
# or: conda install pytorch-cpu torchvision-cpu -c pytorch

conda update --all

开始使用

获取教程数据:github

使用Notebook:dom

# 导入支持库
import torch 

# 确认CUDA支持及其版本
print(torch.version.cuda)
10.0.130
# 查看pytorch帮助
help(torch)
Help on package torch:

NAME
    torch

DESCRIPTION
    The torch package contains data structures for multi-dimensional
    tensors and mathematical operations over these are defined.
    Additionally, it provides many utilities for efficient serializing of
    Tensors and arbitrary types, and other useful utilities.
    
    It has a CUDA counterpart, that enables you to run your tensor computations
    on an NVIDIA GPU with compute capability >= 3.0.

PACKAGE CONTENTS
    _C
    _dl
    _jit_internal
    _nvrtc
    _ops
    _six
    _storage_docs
    _tensor_docs
    _tensor_str
    _thnn (package)
    _torch_docs
    _utils
    _utils_internal
    autograd (package)
    backends (package)
    contrib (package)
    cuda (package)
    distributed (package)
    distributions (package)
    for_onnx (package)
    functional
    hub
    jit (package)
    multiprocessing (package)
    nn (package)
    onnx (package)
    optim (package)
    random
    serialization
    sparse (package)
    storage
    tensor
    testing (package)
    utils (package)
    version
	......
相关文章
相关标签/搜索