---
title: 'anaconda PyTorch 環境架設(ubuntu 20.04)'
disqus: hackmd
---
anaconda PyTorch 環境架設(ubuntu 20.04)
===
[TOC]
## 1. Anaconda 下載與安裝
[Anaconda下載](https://www.anaconda.com/products/individual#windows)

## 2. 使用 Anaconda Prompt(anaconda3) 創建 python3.7 環境
創造一個 conda for PyTorch 環境
```gherkin=
conda create -n pytorch python=3.7
```
切進環境
```gherkin=
conda activate pytorch
```

## 3.安裝 PyTorch
[獲得安裝指令](https://pytorch.org/get-started/locally/)

```gherkin=
conda activate pytorch
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
```
安裝後驗證
```gherkin=
conda activate pytorch
python
import torch
```

```gherkin=
import torchvision
torchvision.__version__
```

驗證 CUDA 是否可用
```gherkin=
torch.cuda.is_available()
torch.cuda.get_device_name()
```

```gherkin=
torch.cuda.device_count()
```

CUDA ID
```gherkin=
torch.cuda.current_device()
```

CUDA 裝置名稱
```gherkin=
torch.cuda.get_device_name(0)
```

## 4.安裝 conda 相關套件
```gherkin=
pip install jupyterlab
conda install -c conda-forge matplotlib -n pytorch
conda install -c anaconda pandas -n pytorch
pip install torchsummary
pip install torch
pip install opencv-python
pip install opencv-contrib-python
```
###### tags: `setup`, `Python`