Pytorch compiled with ROCm.
Highly recommend to use Anaconda3.
Install ROCm, Then install required packages:
sudo apt install rock-dkms rocm-dev rocm-libs miopen-hip hipsparse rccl
sudo apt install libopenblas-dev cmake libnuma-dev autoconf build-essential ca-certificates curl libgoogle-glog-dev libhiredis-dev libiomp-dev libleveldb-dev liblmdb-dev libopencv-dev libpthread-stubs0-dev libsnappy-dev libprotobuf-dev protobuf-compiler
pip install enum34 numpy pyyaml setuptools typing cffi future hypothesis
Get Pytorch source code from ROCmSoftwarePlatform.
git clone --recursive https://github.com/ROCmSoftwarePlatform/pytorch.git
cd pytorch
/opt/rocm/bin/rocm_agent_enumerator
It will show your ROCm devices, select the target, Note: gfx906 is my device for demo
export PYTORCH_ROCM_ARCH=gfx906
patch pytorch code for hipify.
python tools/amd_build/build_amd.py
export USE_NINJA=1
USE_CUDA=0 USE_ROCM=1 USE_LMDB=1 USE_OPENCV=1 MAX_JOBS=2 python setup.py bdist_wheel
Pytorch whl file compiled will be put in dist/
folder, install it whit pip.
pip install dist/*.whl
a simple test for gpu available.
python -c "import torch;print('Torch gpu is available: ', torch.cuda.is_available())"