Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- BOJ
- RegionProposalNetworks
- gpumemory
- 아이폰원스토어
- 선형대수학
- ㅐㅕ세ㅕㅅ
- 선대
- CS231nAssignment1
- CS231nAssignments
- CS231ntwolayerneuralnet
- pycharmerror
- MacOS
- Linear algebra
- CS231nSVM
- arm칩에안드로이드
- CNN구조정리
- BAEKJOON
- MIT
- CS231n
- ios원스토어
- 백준
- Algorithm
- Gilbert Strang
- 백준알고리즘
- adversarialattackonmonoculardepthestimation
- monoculardepthestimation
- 맥실리콘
- professor strang
- CNNarchitecture
- 맥북원스토어
Archives
- Today
- Total
개발로 하는 개발
Using PyTorch GPU acceleration on Mac Silicon M1 pro 본문
Make a venv with the local python > 3.8
python -m venv torchaccel
Activate the venv
source torchaccel/bin/activate
Get the installation code from here
Run it on the (venv) shell. I used Pip.
# MPS acceleration is available on MacOS 12.3+
pip3 install torch torchvision torchaudio
To check if torch is installed, in python, run
import torch
x = torch.rand(5, 3)
print(x)
you may check it from the official website too.
You must modify the main code like this to use 'mps' as a torch device.
# in the main python code,
# Declaration of device must be like this
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
# Change it to this
device = torch.device('cuda:0' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))
You are good to go!
If you want to check if it is installed and torch can find 'mps',
In the venv, write "python"
# In the shell, write "python" to activate python.
# Then, write down this code. It would print 'mps'
import torch
device = torch.device('cuda:0' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))
print(device)
'Tips' 카테고리의 다른 글
MathJax, LaTeX Tistory에 사용해 수식 입력하기 (0) | 2024.01.31 |
---|---|
CV Terms (0) | 2024.01.16 |
Manually Installing OpenCV on venv (0) | 2024.01.08 |
MAC OS X에서 OneDrive 데스크탑 앱 사용하기 (0) | 2023.12.30 |
Xcode에서 깨지는 코드 UTF-8로 수정하기 - 터미널에서 강제 수정 (0) | 2023.12.30 |