Last active
May 15, 2024 19:51
-
-
Save sroecker/f52646023d45ab4e281ddee05d6ef2a5 to your computer and use it in GitHub Desktop.
If this is not crashing then PyTorch is most likely running with your AMD graphics card and ROCm, if not see magic variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
print("pytorch version: " + torch.__version__) | |
print("CUDA available: " + str(torch.cuda.is_available())) | |
print("device count: " + str(torch.cuda.device_count())) | |
print("current device: " + str(torch.cuda.current_device())) | |
print("device name: " + torch.cuda.get_device_name(torch.cuda.current_device())) | |
print("backend:") | |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
print(device) | |
print("small matmul") | |
a = torch.rand(3, 3).to(device) | |
b = torch.rand(3, 3).to(device) | |
res = torch.matmul(a, b) | |
print(res) | |
print(res.size()) | |
print("larger matmul") | |
a = torch.rand(1280, 1280).to(device) | |
b = torch.rand(1280, 1280).to(device) | |
res = torch.matmul(a, b) | |
print(res) | |
print(res.size()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first test if it works without hip | |
# hide all hip devices | |
HIP_VISIBLE_DEVICES= | |
python debug_pytorch_rocm.py | |
# some programs don't work with multi gpu setups, to hide all other than first card | |
HIP_VISIBLE_DEVICES=0 | |
python debug_pytorch_rocm.py | |
# find out the architecture of your card | |
amdgpu-arch | |
# architecture of my card, 6600 M (same for XT) is gfx1032 | |
#export PYTORCH_ROCM_ARCH="gfx1032" | |
#export HSA_OVERRIDE_GFX_VERSION=10.3.2 | |
# pytorch was only compiled for certain supported archs though | |
# https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/3rd-party/pytorch-install.html | |
# so we tell it to use a compatible supported architecture | |
# PLEASE MAKE SURE TO CHOOSE A COMPATIBLE ARCH | |
export PYTORCH_ROCM_ARCH="gfx1030" | |
export HSA_OVERRIDE_GFX_VERSION=10.3.0 | |
# NOT NEEDED set compiler target, HSA_OVERRIDE_GFX_VERSION should set that too | |
# export HCC_AMDGPU_TARGET=gfx1030 | |
python debug_pytorch_rocm.py | |
# this should work now :D | |
# if not, increase log level from 1 to 3 | |
AMD_LOG_LEVEL=3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment