30 , buildDocs ? false # Needs internet
34 stdenv.mkDerivation (finalAttrs: {
35 pname = "mivisionx-" + (
36 if (!useOpenCL && !useCPU) then "hip"
37 else if (!useOpenCL && !useCPU) then "opencl"
43 src = fetchFromGitHub {
46 rev = "rocm-${finalAttrs.version}";
47 hash = "sha256-jmOgwESNALQt7ctmUY9JHgKq47tCwsW1ybynkX9236U=";
51 ../../6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch
59 ] ++ lib.optionals buildDocs [
61 python3Packages.python
80 python3Packages.pybind11
82 python3Packages.torchWithRocm
87 "-DAMDRPP_PATH=${rpp}"
88 # Manually define CMAKE_INSTALL_<DIR>
89 # See: https://github.com/NixOS/nixpkgs/pull/197838
90 "-DCMAKE_INSTALL_BINDIR=bin"
91 "-DCMAKE_INSTALL_LIBDIR=lib"
92 "-DCMAKE_INSTALL_INCLUDEDIR=include"
93 "-DCMAKE_INSTALL_PREFIX_PYTHON=lib"
94 # "-DAMD_FP16_SUPPORT=ON" `error: typedef redefinition with different types ('__half' vs 'half_float::half')`
95 ] ++ lib.optionals (gpuTargets != [ ]) [
96 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
97 ] ++ lib.optionals (!useOpenCL && !useCPU) [
99 ] ++ lib.optionals (useOpenCL && !useCPU) [
101 ] ++ lib.optionals useCPU [
106 # We need to not use hipcc and define the CXXFLAGS manually due to `undefined hidden symbol: tensorflow:: ...`
107 export CXXFLAGS+="--rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
108 patchShebangs rocAL/rocAL_pybind/examples
110 # Properly find miopengemm and miopen
111 substituteInPlace amd_openvx_extensions/CMakeLists.txt \
112 --replace "miopengemm PATHS \''${ROCM_PATH} QUIET" "miopengemm PATHS ${miopengemm} QUIET" \
113 --replace "miopen PATHS \''${ROCM_PATH} QUIET" "miopen PATHS ${miopen} QUIET" \
114 --replace "\''${ROCM_PATH}/include/miopen/config.h" "${miopen}/include/miopen/config.h"
116 # Properly find turbojpeg
117 substituteInPlace amd_openvx/cmake/FindTurboJpeg.cmake \
118 --replace "\''${TURBO_JPEG_PATH}/include" "${libjpeg_turbo.dev}/include" \
119 --replace "\''${TURBO_JPEG_PATH}/lib" "${libjpeg_turbo.out}/lib"
122 substituteInPlace rocAL/rocAL/rocAL_hip/CMakeLists.txt amd_openvx_extensions/amd_nn/nn_hip/CMakeLists.txt amd_openvx/openvx/hipvx/CMakeLists.txt \
123 --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clang}/bin/clang++"
126 postBuild = lib.optionalString buildDocs ''
127 python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html
130 postInstall = lib.optionalString (!useOpenCL && !useCPU) ''
131 patchelf $out/lib/rocal_pybind*.so --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
132 chmod +x $out/lib/rocal_pybind*.so
135 passthru.updateScript = rocmUpdateScript {
136 name = finalAttrs.pname;
137 owner = finalAttrs.src.owner;
138 repo = finalAttrs.src.repo;
142 description = "Set of comprehensive computer vision and machine intelligence libraries, utilities, and applications";
143 homepage = "https://github.com/ROCm/MIVisionX";
144 license = with licenses; [ mit ];
145 maintainers = teams.rocm.members;
146 platforms = platforms.linux;
147 broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";