{"id":24505688,"url":"https://github.com/caseymcc/instinct-mi25","last_synced_at":"2025-03-15T08:42:10.536Z","repository":{"id":203190221,"uuid":"709022102","full_name":"caseymcc/instinct-mi25","owner":"caseymcc","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-24T16:55:35.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T23:33:17.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caseymcc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-23T21:23:52.000Z","updated_at":"2024-12-13T00:55:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"af980fea-d37d-4f37-8ad5-b4bfd5cc0857","html_url":"https://github.com/caseymcc/instinct-mi25","commit_stats":null,"previous_names":["caseymcc/instinct-mi25"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Finstinct-mi25","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Finstinct-mi25/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Finstinct-mi25/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Finstinct-mi25/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caseymcc","download_url":"https://codeload.github.com/caseymcc/instinct-mi25/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707298,"owners_count":20334614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-21T23:31:13.482Z","updated_at":"2025-03-15T08:42:10.518Z","avatar_url":"https://github.com/caseymcc.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to work with the AMD Instinct MI-25\n\nFirst off I started my journey after watching Wendell on [LevelOne Techs](https://www.level1techs.com/) on the MI-25, which led me to this post on their [forums](https://forum.level1techs.com/t/mi25-stable-diffusions-100-hidden-beast/194172). Although it is a great post and I likely would not have gotten it working with out it, actually getting something running took a lot more than just that post.\n\nFirst and foremost, you have to have a PC that supports both `4G Decoding` and `Resizable BAR`. I started with a PC without both, then one with `4G Decode` using an AMD A10 (which did not work) and finally got it working with the same motherboard with a Ryzen (Instead of the A10) which opend up the `Re Size BAR Support`.\n\nYou need to set the following in the bios, each bios varies so it will be something like the below.\n\n```\nAbove 4G Decoding - Enabled\nRe Size BAR Support - Enabled\n\nCSM - Disabled\n```\n\nIf you are not planning to use the `MI-25` as a gpu with video out, then you can skip everything about changing the bios. I did not test the bios changes as I never planned to use it as video out.\n\n## Installing Linux\n\nAs the LevelOne Tech post notes you need specific Linux kernels to get it working, AMD's ROCm only supports certain [ones](https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html). I can say for sure that you do not need the specific kernel called out in the post as mine is 5.15.0-XX. In the end I went with the Ubuntu version (20.04.03) in the post however I ended up working fine on the updated Kernel it had (if I get a chance I want to try other versions)\n\nGrab the Ubuntu version `20.04.03` from [here](https://old-releases.ubuntu.com/releases/20.04.3/). It comes with the kernel version\n```\nLinux zeus 5.15.0-87-generic #97~20.04.1-Ubuntu SMP Thu Oct 5 08:25:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux\n```\nAgain not sure if other kernels can be handled yet so it is in your best interest to not let it update after the install.\n\n## Installing ROCm\n\nYou will need to install ROCm, get the [5.2.5 deb](http://repo.radeon.com/amdgpu-install/22.20.5/ubuntu/focal/). Support for the `MI-25` has been discontinued after `ROCm 4.5.2` however this version seems to still support it (later versions need to be tested as well). [AMD's install instructions](https://rocm.docs.amd.com/en/latest/deploy/linux/installer/install.html)\n\nOnce the download completes you can then install it with the following\n```\nsudo dpkg -i amdgpu-install_22.20.50205-1_all.deb\n```\nOnce the install completes you will need to run `amdgpu-install`\n```\namdgpu-install --usecase=rocm\n```\nthe post list more usecases, however it seems rocm covers all those cases as all the others will be installed.\n\nWhen the install is complete, you need to add the current user to the `video` and `render` groups.\n```\nsudo usermod -a -G video $USER\nsudo usermod -a -G render $USER\n```\nNow make sure to reboot the system. After the reboot you can check if ROCm is able to talk with the `MI-25` using the following\n\n```\n/opt/rocm/bin/rocminfo\nROCk module is loaded\n=====================\nHSA System Attributes\n=====================\nRuntime Version:         1.1\nSystem Timestamp Freq.:  1000.000000MHz\nSig. Max Wait Duration:  18446744073709551615 (0xFFFFFFFFFFFFFFFF) (timestamp count)\nMachine Model:           LARGE\nSystem Endianness:       LITTLE\n\n==========\nHSA Agents\n==========\n*******\nAgent 1\n*******\n  Name:                    AMD Ryzen 5 5600G with Radeon Graphics\n  ...\n  Device Type:             CPU\n  ...\n*******\nAgent 2\n*******\n  Name:                    gfx900\n  ...\n  Device Type:             GPU\n  ...\n*******\nAgent 3\n*******\n  Name:                    gfx90c\n  ...\n  Device Type:             GPU\n  ...\n*** Done ***\n```\nYou can see that on my machine ROCm has picked up the\n```\nAgent 1 - CPU\nAgent 2 - MI-25\nAgent 3 - Integrated GPU\n```\n\nYou can also use the following\n```\n/opt/rocm/bin/rocm-smi --showproductname\n\n\n======================= ROCm System Management Interface =======================\n================================= Product Info =================================\nGPU[0]\t\t: Card series: \t\tVega 10 [Radeon Instinct MI25]\nGPU[0]\t\t: Card model: \t\tRadeon PRO V320\nGPU[0]\t\t: Card vendor: \t\tAdvanced Micro Devices, Inc. [AMD/ATI]\nGPU[0]\t\t: Card SKU: \t\tD05135\nGPU[1]\t\t: Card series: \t\t0x1638\nGPU[1]\t\t: Card model: \t\tRadeon RX Vega 11\nGPU[1]\t\t: Card vendor: \t\tAdvanced Micro Devices, Inc. [AMD/ATI]\nGPU[1]\t\t: Card SKU: \t\tCEZANN\n================================================================================\n============================= End of ROCm SMI Log ==============================\n\n```\nto get a list of devices, this will show the `device index` used by anything calling ROCm. As you can see, although the `MI-25` is `Agent 2` it is seen as device `0` (`GPU[0]`). This can be helpfull as if you have multiple ROCm supported devices some of those devices may not be supported by the tools (pytorch, etc...) and you will need to force the tool to use a specific device/s.\n\n## ROCm with Docker/Pytorch\n\nAs you can see from this repo I went with running the apps in dockers. AMD does not require anything special about the Docker install to use the device in the docker, other than adding the device to the container.\n\nInstall docker like [normal](https://docs.docker.com/desktop/install/ubuntu/). Once installed you can test that docker is working with [AMD's ROCm dockers](https://github.com/RadeonOpenCompute/ROCm-docker).\n\n```\nsudo docker pull rocm/rocm-terminal\nsudo docker run -it --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video rocm/rocm-terminal\n```\nOnce in the docker you should be able to run the above `/opt/rocm/bin/rocminfo`/`rocm-smi`. If you run into any issues (I did) see [Troubleshooting/Docker](#docker---unable-to-open-devkfd-read-write-permission-denied)\n\n\n## Runing automatic1111 Stable Diffusion\nWorking on it\n\n## Runing ConfyUI\nI started with the dockers/scripts from [YanWenKan/ComfyUI-Docker](https://github.com/YanWenKun/ComfyUI-Docker), however I ran into a few issues so I changed to what is in this repo.\n\nMain things:\n- Use Ubuntu base\n- Install ROCm 5.3\n- Setup render group\n- add start script\n- set CUDA_VISIBLE_DEVICES (maybe turn into config file)\n\nAssuming your setup is similar to my own you can start the ComfyUI by running\n```\n./run_docker.sh\n```\n\n## Running LLama-cpp\nWorking on it\n\n## Troubleshooting\n\n### “[amdgpu] trn=2 ack should not assert”!\nIf you are getting the above either on Ubuntu boot or via `dmesg`. There seems to be two main things that cause it\n1. Missing `Above 4G Decoding`/`Resizable BAR` support (either not enabled or system does not support)\n2. `CSM` is enabled\n\ncheck your bios for the above and try again.\n\n### Docker - \"Unable to open /dev/kfd read-write: Permission denied\"\nThis generally means that the user of the docker is not a member of the `video`/`render` groups. The ROCm documentation seems to imply that this works fine with just including `--group-add video` in the `docker run` call. However on my system the `render` group owns `/dev/kfd`.\n```\nls -al /dev/kfd\ncrw-rw---- 1 root render 511, 0 Oct 21 12:09 /dev/kfd\n\n```\nI am assuming this is because I have a supported AMD gpu that is somehow changing who the final owner is. You can change the ownership of the `/dev/kfd` to the `video` group, however on reboot it seems to be reset to the `render` group. My solution to this is to copy to the docker image the `render` group id using docker `BUILDKIT` and the following code\n\n```\nDOCKER_BUILDKIT=1 docker build \\\n    ...\n    --build-arg RENDER_GROUP_ID=$(getent group render | cut -d: -f3)\n    ...\n```\nand creating and assigning the group to the docker user (in this case `runner`) in the docker using\n```\nRUN if [ ${RENDER_GROUP_ID:-0} -ne 0 ]; then \\\n    groupadd -g ${RENDER_GROUP_ID} render \\\n;fi\n...\nRUN useradd --create-home -G sudo,video,render --shell /bin/bash runner\n```\n\n### Docker - RuntimeError: HIP error: invalid argument\nThis is likely caused by the docker containing an incompatible version of `ROCm` than the `ROCm` drivers on the host. Try to installing the same `ROCm` version in the docker as what is on the host. If you are trying to use `pytorch` with `ROCm` and using the pip installer, rather than using the nightly with\n```\npip install --break-system-packages --pre torch torchvision \\\n        --index-url https://download.pytorch.org/whl/nightly/rocm5.7\n```\nuse the standard version with `ROCm`` 5.2 or 5.3\n```\npip install --break-system-packages torch torchvision \\\n        --index-url https://download.pytorch.org/whl/rocm5.3\n```\n\n### Docker - \"hipErrorNoBinaryForGpu: Unable to find code object for all current devices!\"\nThis is likely caused by `pytorch` trying to open an unsupported device. You can tell `pytorch` which devices to use by setting `CUDA_VISIBLE_DEVICES`. In my case since the `MI-25` is index 0 (see `rocm-smi` above), using the following fixes the issue\n```\nexport CUDA_VISIBLE_DEVICES=0\n```\nyou can also add the above to the `./run_docker.sh` vi `--env`\n```\ndocker create -it --name $CONTAINER_NAME \\\n    ...\n    --env CUDA_VISIBLE_DEVICES=0 \\\n    ...\n    $DOCKER_NAME\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaseymcc%2Finstinct-mi25","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaseymcc%2Finstinct-mi25","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaseymcc%2Finstinct-mi25/lists"}