Try   HackMD

anaconda PyTorch 環境架設(ubuntu 20.04)

1. Anaconda 下載與安裝

Anaconda下載

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

2. 使用 Anaconda Prompt(anaconda3) 創建 python3.7 環境

創造一個 conda for PyTorch 環境

conda create -n pytorch python=3.7

切進環境

conda activate pytorch

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

3.安裝 PyTorch

獲得安裝指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

conda activate pytorch conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

安裝後驗證

conda activate pytorch python import torch

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

import torchvision torchvision.__version__

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

驗證 CUDA 是否可用

torch.cuda.is_available() torch.cuda.get_device_name()

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

torch.cuda.device_count()

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

CUDA ID

torch.cuda.current_device()

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

CUDA 裝置名稱

torch.cuda.get_device_name(0)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

4.安裝 conda 相關套件

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