Skip to content

How to run on Linux with AMD #9

@awu0403

Description

@awu0403

Tested with RX 7900 under Fedora 43, using Distrobox for the actual runtime environment.

You may need to edit modules/ui.py, because Wayland has some issues with Window sizing:

def fit_image_to_size(image, width: int, height: int):
if width is None and height is None:
return image
h, w, _ = image.shape

# SAFETY PATCH: If the window hasn't drawn yet, return the original image
if width < 1 or height < 1:
    return image

ratio_h = 0.0
ratio_w = 0.0
if width > height:
    ratio_h = height / h
else:
    ratio_w = width / w
ratio = max(ratio_w, ratio_h)
new_size = (int(ratio * w), int(ratio * h))

# SAFETY PATCH: If calculated size is zero, return original
if new_size[0] < 1 or new_size[1] < 1:
    return image

return cv2.resize(image, dsize=new_size)

Steps
highly recommend distrobox to create a base container with all necessary dependencies
create new distrobox based on image rocm/onnxruntime:rocm7.0_ub24.04_ort1.22_torch2.8.0
this is the last ROCm version supported before the switch to MiGraphX, which I couldn't get working
sudo apt install git ffmpeg
find Python package for ONNX runtime, probably here (ROCM 7.0.2 in this example, but navigate yourself if missing)
make sure the package you choose matches the python version you have installed (3.12, probably)
copy that link
navigate to this repository folder
create a venv via python -m venv venv
source venv/bin/activate
pip uninstall onnxruntime onnxruntime-gpu to uninstall default provided dependencies
(you can try: pip install onnxruntime-rocm but it may not be the matching version you're hoping for)
remove onnxruntime-gpu from requirements.txt
pip install -r requirements.txt
pip install
python -c "import onnxruntime; print(onnxruntime.get_available_providers())" should now show AMD ROCm
python3 run.py --execution-provider rocm should start the program

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions