-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
AMD GPU support with the rocm detector and YOLOv8 pretrained model download #9762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
42f1168
ROCm AMD/GPU based build and detector, WIP
harakas d88accf
detectors/rocm: separate yolov8 postprocessing into own function; fix…
harakas 35ae69a
AMD/ROCm: add couple of more ultralytics models; comments
harakas fb2425e
docker/rocm: make imported model files readable by all
harakas bb0836b
docker/rocm: readme about running on AMD GPUs
harakas 60ea2a4
docker/rocm: updated README
harakas 6de14a4
docker/rocm: updated README
harakas c93a508
docker/rocm: updated README
harakas 622a45e
detectors/rocm: separated preprocessing functions into yolo_utils.py
harakas af3e40d
detector/plugins: added onnx cpu plugin
harakas 252a5dd
docker/rocm: updated container with limite label sets
harakas 4481d08
example detectors view
harakas 3747b8e
docker/rocm: updated README.md
harakas 917561b
docker/rocm: update README.md
harakas 2634348
docker/rocm: do not set HSA_OVERRIDE_GFX_VERSION at all for the gener…
harakas de02ba7
detectors: simplified/optimized yolov8_postprocess
harakas da31ee1
detector/yolo_utils: indentation, remove unused variable
harakas 6171311
detectors/rocm: default option to conserve cpu usage at the expense o…
harakas cd50898
detectors/yolo_utils: use nms to prefilter overlapping boxes if too m…
harakas 80ae30e
detectors/edgetpu_tfl: add support for yolov8
harakas d6ff220
util/download_models: script to download yolov8 model files
harakas 7c58c3e
docker/main: add download-models overlay into s6 startup
harakas b151bcc
detectors/rocm: assume models are in /config/model_cache/yolov8/
harakas 8a14703
docker/rocm: compile onnx files into mxr files at startup
harakas 77fc38c
switch model download into bash script
harakas 24cae6d
detectors/rocm: automatically override HSA_OVERRIDE_GFX_VERSION for c…
harakas 1942783
docs: rocm detector first notes
harakas c037c18
typos
harakas 80bb349
describe builds (harakas temporary)
harakas d35a2f1
docker/rocm: also build a version for gfx1100
harakas b2d26c9
docker/rocm: use cp instead of tar
harakas 4bcb071
docker.rocm: remove README as it is now in detector config
harakas a982698
frigate/detectors: renamed yolov8_preprocess->preprocess, pass input …
harakas dee95de
docker/main: use newer openvino (2023.3.0)
harakas dcfe6bb
detectors: implement class aggregation
harakas c2baac6
update yolov8 model
harakas 35cc6a1
add openvino/yolov8 support for label aggregation
harakas d117da4
docker: remove pointless s6/timeout-up files
harakas 4dc7502
Revert "detectors: implement class aggregation"
harakas 79b88c9
detectors/openvino: remove class aggregation
harakas 4318b5a
detectors: increase yolov8 postprocessing score trershold to 0.5
harakas a00fe53
docker/rocm: separate rocm distributed files into its own build stage
harakas 7b2331b
Update object_detectors.md
harakas d09102a
Merge branch 'blakeblackshear:dev' into dev
harakas 86cf8fa
updated CODEOWNERS file for rocm
harakas 7237a79
updated build names for documentation
harakas 6a2078c
Revert "docker/main: use newer openvino (2023.3.0)"
harakas 3a96495
reverrted openvino detector
harakas d0a8824
reverted edgetpu detector
harakas 755fbbc
scratched rocm docs from any mention of edgetpu or openvino
harakas e7da205
Update docs/docs/configuration/object_detectors.md
harakas 146aee7
renamed frigate.detectors.yolo_utils.py -> frigate.detectors.util.py
harakas 5a2333c
clarified rocm example performance
harakas 4b1a4dd
Improved wording and clarified text
harakas 8c96d3a
Mentioned rocm detector for AMD GPUs
harakas 128ed4d
applied ruff formating
harakas 8e20559
applied ruff suggested fixes
harakas e518186
docker/rocm: fix missing argument resulting in larger docker image sizes
harakas cfc1bf4
docs/configuration/object_detectors: fix links to yolov8 release files
harakas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Empty file.
34 changes: 34 additions & 0 deletions
34
docker/main/rootfs/etc/s6-overlay/s6-rc.d/download-models/run
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Download yolov8 models when DOWNLOAD_YOLOV8=1 environment variable is set | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
MODEL_CACHE_DIR=${MODEL_CACHE_DIR:-"/config/model_cache"} | ||
YOLOV8_DIR="$MODEL_CACHE_DIR/yolov8" | ||
YOLOV8_URL=https://github.com/harakas/models/releases/download/yolov8.1-1.1/yolov8.small.models.tar.gz | ||
YOLOV8_DIGEST=304186b299560fbacc28eac9b9ea02cc2289fe30eb2c0df30109a2529423695c | ||
|
||
if [ "$DOWNLOAD_YOLOV8" = "1" ]; then | ||
echo "download-models: DOWNLOAD_YOLOV8=${DOWNLOAD_YOLOV8}, running download" | ||
if ! test -f "${YOLOV8_DIR}/model.fetched"; then | ||
mkdir -p $YOLOV8_DIR | ||
TMP_FILE="${YOLOV8_DIR}/download.tar.gz" | ||
curl --no-progress-meter -L --max-filesize 500M --insecure --output $TMP_FILE "${YOLOV8_URL}" | ||
digest=$(sha256sum $TMP_FILE | awk '{print $1}') | ||
if [ "$digest" = "$YOLOV8_DIGEST" ]; then | ||
echo "download-models: Extracting downloaded file" | ||
cd $YOLOV8_DIR | ||
tar zxf $TMP_FILE | ||
rm $TMP_FILE | ||
touch model.fetched | ||
echo "download-models: Yolov8 download done, files placed into ${YOLOV8_DIR}" | ||
else | ||
echo "download-models: Downloaded file digest does not match: got $digest, expected $YOLOV8_DIGEST" | ||
rm $TMP_FILE | ||
fi | ||
else | ||
echo "download-models: ${YOLOV8_DIR}/model.fetched already present" | ||
fi | ||
fi | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
oneshot |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/etc/s6-overlay/s6-rc.d/download-models/run |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG ROCM=5.7.3 | ||
ARG AMDGPU=gfx900 | ||
ARG HSA_OVERRIDE_GFX_VERSION | ||
ARG HSA_OVERRIDE | ||
|
||
####################################################################### | ||
FROM ubuntu:focal as rocm | ||
|
||
ARG ROCM | ||
|
||
RUN apt-get update && apt-get -y upgrade | ||
RUN apt-get -y install gnupg wget | ||
|
||
RUN mkdir --parents --mode=0755 /etc/apt/keyrings | ||
|
||
RUN wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null | ||
COPY docker/rocm/rocm.list /etc/apt/sources.list.d/ | ||
COPY docker/rocm/rocm-pin-600 /etc/apt/preferences.d/ | ||
|
||
RUN apt-get update | ||
|
||
RUN apt-get -y install --no-install-recommends migraphx | ||
RUN apt-get -y install --no-install-recommends migraphx-dev | ||
|
||
RUN mkdir -p /opt/rocm-dist/opt/rocm-$ROCM/lib | ||
RUN cd /opt/rocm-$ROCM/lib && cp -dpr libMIOpen*.so* libamd*.so* libhip*.so* libhsa*.so* libmigraphx*.so* librocm*.so* librocblas*.so* /opt/rocm-dist/opt/rocm-$ROCM/lib/ | ||
RUN cd /opt/rocm-dist/opt/ && ln -s rocm-$ROCM rocm | ||
|
||
RUN mkdir -p /opt/rocm-dist/etc/ld.so.conf.d/ | ||
RUN echo /opt/rocm/lib|tee /opt/rocm-dist/etc/ld.so.conf.d/rocm.conf | ||
|
||
####################################################################### | ||
FROM --platform=linux/amd64 debian:11 as debian-base | ||
|
||
RUN apt-get update && apt-get -y upgrade | ||
RUN apt-get -y install --no-install-recommends libelf1 libdrm2 libdrm-amdgpu1 libnuma1 kmod | ||
|
||
RUN apt-get -y install python3 | ||
|
||
####################################################################### | ||
# ROCm does not come with migraphx wrappers for python 3.9, so we build it here | ||
FROM debian-base as debian-build | ||
|
||
ARG ROCM | ||
|
||
COPY --from=rocm /opt/rocm-$ROCM /opt/rocm-$ROCM | ||
RUN ln -s /opt/rocm-$ROCM /opt/rocm | ||
|
||
RUN apt-get -y install g++ cmake | ||
RUN apt-get -y install python3-pybind11 python3.9-distutils python3-dev | ||
|
||
WORKDIR /opt/build | ||
|
||
COPY docker/rocm/migraphx . | ||
|
||
RUN mkdir build && cd build && cmake .. && make install | ||
|
||
####################################################################### | ||
FROM deps AS deps-prelim | ||
|
||
# need this to install libnuma1 | ||
RUN apt-get update | ||
# no ugprade?!?! | ||
RUN apt-get -y install libnuma1 | ||
|
||
WORKDIR /opt/frigate/ | ||
COPY --from=rootfs / / | ||
COPY docker/rocm/rootfs/ / | ||
|
||
####################################################################### | ||
FROM scratch AS rocm-dist | ||
|
||
ARG ROCM | ||
ARG AMDGPU | ||
|
||
COPY --from=rocm /opt/rocm-$ROCM/bin/rocminfo /opt/rocm-$ROCM/bin/migraphx-driver /opt/rocm-$ROCM/bin/ | ||
COPY --from=rocm /opt/rocm-$ROCM/share/miopen/db/*$AMDGPU* /opt/rocm-$ROCM/share/miopen/db/ | ||
COPY --from=rocm /opt/rocm-$ROCM/lib/rocblas/library/*$AMDGPU* /opt/rocm-$ROCM/lib/rocblas/library/ | ||
COPY --from=rocm /opt/rocm-dist/ / | ||
COPY --from=debian-build /opt/rocm/lib/migraphx.cpython-39-x86_64-linux-gnu.so /opt/rocm-$ROCM/lib/ | ||
|
||
####################################################################### | ||
FROM deps-prelim AS rocm-prelim-hsa-override0 | ||
|
||
ENV HSA_ENABLE_SDMA=0 | ||
|
||
COPY --from=rocm-dist / / | ||
|
||
RUN ldconfig | ||
|
||
####################################################################### | ||
FROM rocm-prelim-hsa-override0 as rocm-prelim-hsa-override1 | ||
|
||
ARG HSA_OVERRIDE_GFX_VERSION | ||
ENV HSA_OVERRIDE_GFX_VERSION=$HSA_OVERRIDE_GFX_VERSION | ||
|
||
####################################################################### | ||
FROM rocm-prelim-hsa-override$HSA_OVERRIDE as rocm-deps | ||
|
||
# Request yolov8 download at startup | ||
ENV DOWNLOAD_YOLOV8=1 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
cmake_minimum_required(VERSION 3.1) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif() | ||
|
||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
project(migraphx_py) | ||
|
||
include_directories(/opt/rocm/include) | ||
|
||
find_package(pybind11 REQUIRED) | ||
pybind11_add_module(migraphx migraphx_py.cpp) | ||
|
||
target_link_libraries(migraphx PRIVATE /opt/rocm/lib/libmigraphx.so /opt/rocm/lib/libmigraphx_tf.so /opt/rocm/lib/libmigraphx_onnx.so) | ||
|
||
install(TARGETS migraphx | ||
COMPONENT python | ||
LIBRARY DESTINATION /opt/rocm/lib | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.