31 buildDocs ? false, # Needs internet
35 stdenv.mkDerivation (finalAttrs: {
39 if (!useOpenCL && !useCPU) then
41 else if (!useOpenCL && !useCPU) then
49 src = fetchFromGitHub {
52 rev = "rocm-${finalAttrs.version}";
53 hash = "sha256-jmOgwESNALQt7ctmUY9JHgKq47tCwsW1ybynkX9236U=";
57 ../../6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch
67 ++ lib.optionals buildDocs [
69 python3Packages.python
88 python3Packages.pybind11
90 python3Packages.torchWithRocm
96 "-DAMDRPP_PATH=${rpp}"
97 # Manually define CMAKE_INSTALL_<DIR>
98 # See: https://github.com/NixOS/nixpkgs/pull/197838
99 "-DCMAKE_INSTALL_BINDIR=bin"
100 "-DCMAKE_INSTALL_LIBDIR=lib"
101 "-DCMAKE_INSTALL_INCLUDEDIR=include"
102 "-DCMAKE_INSTALL_PREFIX_PYTHON=lib"
103 # "-DAMD_FP16_SUPPORT=ON" `error: typedef redefinition with different types ('__half' vs 'half_float::half')`
105 ++ lib.optionals (gpuTargets != [ ]) [
106 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
108 ++ lib.optionals (!useOpenCL && !useCPU) [
111 ++ lib.optionals (useOpenCL && !useCPU) [
114 ++ lib.optionals useCPU [
119 # We need to not use hipcc and define the CXXFLAGS manually due to `undefined hidden symbol: tensorflow:: ...`
120 export CXXFLAGS+="--rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
121 patchShebangs rocAL/rocAL_pybind/examples
123 # Properly find miopengemm and miopen
124 substituteInPlace amd_openvx_extensions/CMakeLists.txt \
125 --replace "miopengemm PATHS \''${ROCM_PATH} QUIET" "miopengemm PATHS ${miopengemm} QUIET" \
126 --replace "miopen PATHS \''${ROCM_PATH} QUIET" "miopen PATHS ${miopen} QUIET" \
127 --replace "\''${ROCM_PATH}/include/miopen/config.h" "${miopen}/include/miopen/config.h"
129 # Properly find turbojpeg
130 substituteInPlace amd_openvx/cmake/FindTurboJpeg.cmake \
131 --replace "\''${TURBO_JPEG_PATH}/include" "${libjpeg_turbo.dev}/include" \
132 --replace "\''${TURBO_JPEG_PATH}/lib" "${libjpeg_turbo.out}/lib"
135 substituteInPlace rocAL/rocAL/rocAL_hip/CMakeLists.txt amd_openvx_extensions/amd_nn/nn_hip/CMakeLists.txt amd_openvx/openvx/hipvx/CMakeLists.txt \
136 --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clang}/bin/clang++"
139 postBuild = lib.optionalString buildDocs ''
140 python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html
143 postInstall = lib.optionalString (!useOpenCL && !useCPU) ''
144 patchelf $out/lib/rocal_pybind*.so --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
145 chmod +x $out/lib/rocal_pybind*.so
148 passthru.updateScript = rocmUpdateScript {
149 name = finalAttrs.pname;
150 owner = finalAttrs.src.owner;
151 repo = finalAttrs.src.repo;
155 description = "Set of comprehensive computer vision and machine intelligence libraries, utilities, and applications";
156 homepage = "https://github.com/ROCm/MIVisionX";
157 license = with licenses; [ mit ];
158 maintainers = teams.rocm.members;
159 platforms = platforms.linux;
161 versions.minor finalAttrs.version != versions.minor stdenv.cc.version
162 || versionAtLeast finalAttrs.version "6.0.0";