Coder Social home page Coder Social logo

pytorch-gfx803's Introduction

PyTorch ROCm gfx803

build pytorch 2.x with ROCm support for stable-diffusion-webui

Ubuntu 22.04.2 LTS
Radeon RX 580 8GB
RoCm 5.4.3
Gcc 11.2.0
Linux 5.19

Python 3.10.6
- pytorch 2.1.0a0
- torchvision 0.16.0a0

Install dependencies

sudo apt install libopenmpi3 libstdc++-12-dev
sudo apt install ninja-build
sudo apt install cmake

Install ROCm

sudo echo ROC_ENABLE_PRE_VEGA=1 >> /etc/environment
sudo echo HSA_OVERRIDE_GFX_VERSION=8.0.3 >> /etc/environment
# reboot

wget https://repo.radeon.com/amdgpu-install/22.40.3/ubuntu/focal/amdgpu-install_5.4.50403-1_all.deb
sudo apt install ./amdgpu-install_5.4.50403-1_all.deb
sudo amdgpu-install -y --usecase=rocm,hiplibsdk,mlsdk

sudo usermod -aG video $LOGNAME
sudo usermod -aG render $LOGNAME

# verify
rocminfo
clinfo

Build

You may need to install addional ependencies, and the build will take a long time.

TL;DR: use the prebuilt binaries if you want to make your life easier.

Build pytorch

git clone --depth=1 https://github.com/pytorch/pytorch.git
cd pytorch
export HIP_PLATFORM=amd
export PATH=/opt/rocm/bin:$PATH ROCM_PATH=/opt/rocm HIP_PATH=/opt/rocm/hip
export PYTORCH_ROCM_ARCH=gfx803
export PYTORCH_BUILD_VERSION=2.1.0a0 PYTORCH_BUILD_NUMBER=1	           # build_version please see the version.txt   
python3.10 tools/amd_build/build_amd.py
USE_ROCM=1 USE_NINJA=1 python3.10 setup.py bdist_wheel
pip3 install dist/torch-2.1.0a0-cp310-cp310-linux_x86_64.whl	

Build torchvision

git clone --depth=1 https://github.com/pytorch/vision.git
cd vision
export BUILD_VERSION=0.16.0a0	                                        # build_version please see the version.txt
FORCE_CUDA=1 ROCM_HOME=/opt/rocm/ python3.10 setup.py bdist_wheel
pip3 install dist/torchvision-0.16.0a0-cp310-cp310-linux_x86_64.whl

Test

# maybe you need: python setup.py develop && python -c "import torch"
python3.10 test_torch.py

Reference

pytorch-gfx803's People

Contributors

tokoshie avatar tsl0922 avatar coldspirit0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.