Skip to content

Commit bc3e04c

Browse files
committed
GPU: Update build documentation for new gpu-system.sh package
1 parent c2f066a commit bc3e04c

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

GPU/documentation/build-O2.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ GPU support should be detected and enabled automatically.
1111
If you just want to reproduce the GPU build locally without running it, it might be easiest to use the GPU CI container (see below).
1212
The provisioning script of the container also demonstrates which patches need to be applied such that everything works correctly.
1313

14+
In a nutshell, all is steered via CMake variables, and the `ALIBUILD_O2_FORCE_GPU...` environment variables exist to steer what [alidist/o2.sh](https://github.com/alisw/alidist/blob/master/o2.sh) puts as CMake defaults.
15+
We try to run the same CMake GPU detection as in O2 ([FindO2GPU.cmake](https://github.com/AliceO2Group/AliceO2/blob/dev/dependencies/FindO2GPU.cmake)) during the aliBuild `prefer_system_check` ([gpu-system.sh](https://github.com/alisw/alidist/blob/master/gpu-system.sh)), such that all GPU features / versions / architectures can become part of the `gpu-system` version, which avoid inconsistencies between different packages we build.
16+
17+
All is steered via environment variables, which will go into the version and thus the hash:
18+
- `ALIBUILD_O2_FORCE_GPU=...` sets the mode
19+
- `ALIBUILD_O2_FORCE_GPU_CUDA=1` can force-enable (`=1`) or disable (`=0`) backends, even if they were not detected. Same for `..._HIP` and `..._OPENCL`.
20+
- `ALIBUILD_O2_FORCE_GPU_CUDA_ARCH=...` can override the architecture to cross-compile, e.g. `ALIBUILD_O2_FORCE_GPU_CUDA_ARCH="86;89"`. Same for `..._HIP_ARCH`.
21+
22+
Modes for `ALIBUILD_O2_FORCE_GPU`
23+
- `force` / `1` / `ci`: Force that all backends / features are detected, fail if not. GPU architectures are set to the default ones if not specified by environment variables.
24+
CI is currently identical to force, but should allow special behavior when running in the CI.
25+
- `auto`: check for supported system-cmake version, fail if not found. Auto-detect GPU backends / features and architectures. Selected features can be force-enabled on top via env variable. But not selectively disabled. (But one can use the manual mode below.)
26+
- `onthefly`: Don't detect GPUs at alidist levels. gPUs disabled in ONNX. GPUs auto-detcted in O2 CMake during build as before, but this means the O2 build hash does not depend on GPU features, so we also have the same problems as before. This is just a fallback, to allow users to build with GPUs if they don't have a compatible system CMake.
27+
- `fullauto`: Detect supported system-cmake. If found, behave as Auto. If not found behave as OnTheFly.
28+
- `disabled`: Disable all GPU builds. No extra time during aliBuild command.
29+
- `manual`: all GPU builds disabled by default, to be enabled manually via env variable. No extra time during aliBuild command.
30+
31+
*Additional reasoning for this approach*
32+
Advantages:
33+
- O2 hash and ONNX hash depend on available GPU backends, detected features (like tensorrt for ML) and on the detected GPU architectures and librar versions. I.e. when you plug in a new GPU or update the CUDA version, the O2 hash will change and this will trigger a rebuild. Otherwise, the build could just fail due to stale settings in CMakeCache.
34+
- We can have binary tarballs depending on the enabled backends.
35+
- O2 and ONNX are always in sync.
36+
- Same detection during aliBuild as in O2 CMake.
37+
- One can see enabled GPU features / versions / architectures in the version string of `gpu-system`.
38+
39+
Disadvantages:
40+
- Need system `CMake` >= `3.26` for the detsction at aliBuild level.
41+
- `FindO2GPU.cmake` is duplicated in O2 and alidist and must be kept in sync. But at least this is checked and gives an error otherwise.
42+
- Running cmake during the system check takes around 5 sec for every aliBuild command involving O2 or ONNX.
43+
1444
*GPU Tracking with CUDA*
1545
* The CMake option `-DENABLE_CUDA=ON/OFF/AUTO` steers whether CUDA is forced enabled / unconditionally disabled / auto-detected.
1646
* The CMake option `-DCUDA_COMPUTETARGET=...` fixes a GPU target, e.g. 61 for PASCAL or 75 for Turing (if unset, it compiles for the lowest supported architecture)
@@ -19,10 +49,9 @@ The provisioning script of the container also demonstrates which patches need to
1949
* CMake will report "Building GPUTracking with CUDA support" when enabled.
2050

2151
*GPU Tracking with HIP*
22-
* HIP and HCC must be installed, and CMake must be able to detect HIP via find_package(hip).
23-
* If HIP and HCC are not installed to /opt/rocm, the environment variables `$HIP_PATH` and `$HCC_HOME` must point to the installation directories.
24-
* HIP from ROCm >= 4.0 is required.
25-
* The CMake option `-DHIP_AMDGPUTARGET=...` forces a GPU target, e.g. gfx906 for Radeon VII (if unset, it auto-detects the GPU).
52+
* HIP must be installed, and CMake must be able to detect HIP via find_package(hip) and enable language(hip).
53+
* For the minimum ROCm / HIP version, please check [FindO2GPU.cmake](https://github.com/AliceO2Group/AliceO2/blob/dev/dependencies/FindO2GPU.cmake#L287).
54+
* The CMake option `-DHIP_AMDGPUTARGET=...` / env variable `ALIBUILD_O2_FORCE_GPU_HIP_ARCH=...` forces a GPU target, e.g. gfx906 for MI50 (if unset, it auto-detects the GPU).
2655
* CMake will report "Building GPUTracking with HIP support" when enabled.
2756
* It may be that some patches must be applied to ROCm after the installation. You find the details in the provisioning script of the GPU CI container below.
2857

@@ -31,7 +60,7 @@ The provisioning script of the container also demonstrates which patches need to
3160
* Needs the SPIR-V LLVM translator together with LLVM to create the SPIR-V binaries, also detectable via CMake.
3261

3362
*OpenGL visualization of TPC tracking*
34-
* Needs the following libraries (all detectable via CMake find_package): libOpenGL, libGLEW, libGLFW, libGLU.
63+
* Needs the following libraries (all detectable via CMake find_package): libOpenGL, libGLEW or libGLFW (default), libGLU.
3564
* OpenGL must be at least version 4.5, but this is not detectable at CMake time. If the supported OpenGL version is below, the display is not/partially built, and not available at runtime. (Whether it is not or partially built depends on whether the maximum OpenGL version supported by GLEW or that of the system runtime in insufficient.)
3665
* Note: If ROOT does not detect the system GLEW library, ROOT will install its own very outdated GLEW library, which will be insufficient for the display. Since the ROOT include path will come first in the order, this will prevent the display from being built.
3766
* CMake will report "Building GPU Event Display" when enabled.
@@ -46,17 +75,16 @@ The provisioning script of the container also demonstrates which patches need to
4675

4776
*Using the GPU CI container*
4877
* Setting up everything locally might be somewhat time-consuming, instead you can use the GPU CI cdocker container.
49-
* The docker images is `alisw/slc8-gpu-builder`.
50-
* The container exports the `ALIBUILD_O2_FORCE_GPU` env variable, which force-enables all GPU builds.
78+
* The docker images is `alisw/slc9-gpu-builder`.
79+
* The container exports the `ALIBUILD_O2_FORCE_GPU=1` env variable, which force-enables all GPU builds.
5180
* Note that it might not be possible out-of-the-box to run the GPU version from within the container. In case of HIP it should work when you forwards the necessary GPU devices in the container. For CUDA however, you would either need to (in addition to device forwarding) match the system CUDA driver and toolkit installation to the files present in the container, or you need to use the CUDA docker runtime, which is currently not installed in the container.
5281
* There are currently some patches needed to install all the GPU backends in a proper way and together. Please refer to the container provisioning script [provision.sh](https://github.com/alisw/docks/blob/master/slc9-gpu-builder/provision.sh). If you want to reproduce the installation locally, it is recommended to follow the steps from the script.
5382

5483
*Summary*
5584

56-
If you want to enforce the GPU builds on a system without GPU, please set the following CMake settings:
57-
* `ENABLE_CUDA=ON`
58-
* `ENABLE_HIP=ON`
59-
* `ENABLE_OPENCL=ON
60-
* `HIP_AMDGPUTARGET=default`
61-
* `CUDA_COMPUTETARGET=default`
62-
Alternatively you can set the environment variables `ALIBUILD_ENABLE_CUDA=1` and `ALIBUILD_ENABLE_HIP=1` to enforce building CUDA or HIP without modifying the alidist scripts.
85+
If you want to enforce the GPU builds on a system without GPU, please export the following environment variables:
86+
* `ALIBUILD_O2_FORCE_GPU_CUDA=ON`
87+
* `ALIBUILD_O2_FORCE_GPU_HIP=ON`
88+
* `ALIBUILD_O2_FORCE_GPU_OPENCL=ON`
89+
* `ALIBUILD_O2_FORCE_GPU_CUDA_ARCH=default`
90+
* `ALIBUILD_O2_FORCE_GPU_HIP_ARCH=default`

0 commit comments

Comments
 (0)