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
	......
相關文章
相關標籤/搜索