ROCm / ROCR-Runtime

ROCm Platform Runtime: ROCr a HPC market enhanced HSA based runtime
https://rocm.docs.amd.com/projects/ROCR-Runtime/en/latest/
Other
224 stars 110 forks source link

[Feature]: Ability to compile an app with statically linked runtime #240

Open nazar-pc opened 1 month ago

nazar-pc commented 1 month ago

Suggestion Description

When compiling software with Nvidia CUDA support there is an option to compile with statically linked runtime, so user doesn't need to install anything other than application itself and GPU driver to run it.

With AMD I don't see a way to do this right now, which means user has to manually install extra software. Moreover, with latest ROCm not available in sock repos on Ubuntu the process is even more involved than a single apt-get install libamdhip64, which is even worse experience.

Please add ability to do this, ideally with both Linux and Windows support, this will be a HUGE improvement for end users leveraging AMD hardware.

I'm currently compiling things with hipcc, so something like a CLI option to statically link libamdhip64 and whatever else it depends on (I see libnuma1 on Linux for some reason).

Operating System

No response

GPU

No response

ROCm Component

runtime

nazar-pc commented 1 month ago

I'm wondering if this is the wrong repository, should it be moved to https://github.com/ROCm/HIP ?

dayatsin-amd commented 1 month ago

Hi @nazar-pc

If you are using the amd-staging, amd-master branches, you should be able to build static libraries using:

cd rocr-runtime

mkdir build && cd build cmake -DCMAKE_INSTALL_PATH=/opt/rocm -DCMAKE_BUILD_TYPE="Debug" -DBUILD_SHARED_LIBS=0 .. make -j 30 make package

nazar-pc commented 1 month ago

I'm not actually compiling it from scratch, I install rocm-hip-runtime-dev from the repository. Also it is not Linux-specific, the app is cross-platform and supports AMD ROCm on Windows as well, where the code is still closed source and I can't compile a static library even if I wanted to.

So I would really like something like --cudart=static. Ideally also not requiring other dynamic libraries if possible.

Right now a whole bunch of AMD libraries are required for ROCm build (first) comparing to CUDA build (second):

/subspace-farmer-rocm:
    linux-vdso.so.1 (0x0000772350bf2000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000772350b02000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x000077234e400000)
    libamdhip64.so.6 => /opt/rocm/lib/libamdhip64.so.6 (0x000077234ca00000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000772350ae2000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000077234c600000)
    /lib64/ld-linux-x86-64.so.2 (0x0000772350bf4000)
    librocprofiler-register.so.0 => /opt/rocm/lib/librocprofiler-register.so.0 (0x000077234e77e000)
    libamd_comgr.so.2 => /opt/rocm/lib/libamd_comgr.so.2 (0x0000772343800000)
    libhsa-runtime64.so.1 => /opt/rocm/lib/libhsa-runtime64.so.1 (0x0000772343400000)
    libnuma.so.1 => /lib/x86_64-linux-gnu/libnuma.so.1 (0x0000772350ad3000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x000077234e762000)
    libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x000077234e730000)
    libelf.so.1 => /lib/x86_64-linux-gnu/libelf.so.1 (0x000077234e712000)
    libdrm.so.2 => /lib/x86_64-linux-gnu/libdrm.so.2 (0x000077234e6fc000)
    libdrm_amdgpu.so.1 => /lib/x86_64-linux-gnu/libdrm_amdgpu.so.1 (0x0000772350ac5000)
/subspace-farmer-cuda:
    linux-vdso.so.1 (0x000078597b6dd000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000785979b19000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000785979800000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000078597b6b4000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000785979400000)
    /lib64/ld-linux-x86-64.so.2 (0x000078597b6df000)