name: Linux CUDA No cuDNN CI on: pull_request: branches: [main, 'rel-*'] paths: - '.github/workflows/linux_cuda_no_cudnn.yml' - 'cmake/onnxruntime_cuda_cccl.cmake' - 'cmake/onnxruntime_providers_cuda.cmake' - 'cmake/onnxruntime_python.cmake' - 'onnxruntime/__init__.py' - 'onnxruntime/core/providers/cuda/**' workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} cancel-in-progress: true permissions: contents: read packages: write attestations: write id-token: write jobs: build-linux-cuda-no-cudnn-x64-release: name: Build Linux CUDA x64 Release without cuDNN link uses: ./.github/workflows/reusable_linux_build.yml with: pool_name: "onnxruntime-github-Ubuntu2204-AMD-CPU" build_config: Release architecture: x64 dockerfile_path: tools/ci_build/github/linux/docker/Dockerfile.manylinux2_28_cuda docker_build_args: '--build-arg BASEIMAGE=onnxruntimebuildcache.azurecr.io/internal/azureml/onnxruntime/build/cuda13_x64_almalinux8_gcc14:20251107.1' docker_image_repo: onnxruntimecuda13manylinuxbuild extra_build_flags: >- --use_binskim_compliant_compile_flags --build_wheel --parallel --nvcc_threads 4 --flash_nvcc_threads 4 --cuda_version=13.0 --cuda_home=/usr/local/cuda-13.0 --cudnn_home=/usr/local/cuda-13.0 --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES=86 --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=ON --cmake_extra_defines onnxruntime_QUICK_BUILD=ON --cmake_extra_defines onnxruntime_USE_FPA_INTB_GEMM=OFF python_path_prefix: 'PATH=/opt/python/cp312-cp312/bin:$PATH' run_tests: false upload_build_output: true execution_providers: 'cuda' job_identifier: build-linux-cuda-no-cudnn-x64-release secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} smoke-linux-cuda-no-cudnn-x64-release: name: Smoke Linux CUDA x64 Release without cuDNN runtime use needs: build-linux-cuda-no-cudnn-x64-release runs-on: - self-hosted - "1ES.Pool=onnxruntime-github-linux-a10" - "1ES.ImageOverride=onnxruntime-ubuntu2204-CUDA-A10" - "JobId=smoke-linux-cuda-no-cudnn-x64-release-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" timeout-minutes: 210 permissions: contents: read packages: read steps: - name: Checkout code uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - uses: microsoft/onnxruntime-github-actions/build-docker-image@8bad63a3c05d448311dfa8e5f531171c97471aa1 # v0.0.12 id: build_docker_image_step with: dockerfile: ${{ github.workspace }}/tools/ci_build/github/linux/docker/Dockerfile.manylinux2_28_cuda image-name: ghcr.io/microsoft/onnxruntime/onnxruntimecuda13manylinuxbuild build-args: '--build-arg BASEIMAGE=onnxruntimebuildcache.azurecr.io/internal/azureml/onnxruntime/build/cuda13_x64_almalinux8_gcc14:20251107.1' push: true azure-container-registry-name: onnxruntimebuildcache env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download Build Artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: build-output-x64-Release path: ${{ runner.temp }}/Release - name: Restore Executable Permissions working-directory: ${{ runner.temp }}/Release run: | if [ -f perms.txt ]; then while IFS= read -r file; do if [ -f "$file" ]; then chmod +x "$file" fi done < perms.txt fi - name: Verify CUDA provider has no direct cuDNN or cuFFT dependency run: | docker run --rm --gpus all \ -v "${{ runner.temp }}/Release:/build/Release" \ "${{ steps.build_docker_image_step.outputs.full-image-name }}" \ bash -lc 'set -euo pipefail ldd /build/Release/Release/libonnxruntime_providers_cuda.so | tee /tmp/ldd.txt ! grep -i cudnn /tmp/ldd.txt ! grep -i cufft /tmp/ldd.txt' - name: Run no-cuDNN CUDA EP op smoke test run: | # The build image runs as a non-root user by default, but this step # deletes the system cuDNN libraries and rebuilds the dynamic linker # cache (both require root). Run this disposable test container as root. docker run --rm --gpus all --user root \ -v "${{ runner.temp }}/Release:/build/Release" \ "${{ steps.build_docker_image_step.outputs.full-image-name }}" \ bash -lc 'set -e PATH=/opt/python/cp312-cp312/bin:$PATH LD_LIBRARY_PATH=/usr/local/cuda-13.0/lib64:${LD_LIBRARY_PATH:-} export PATH LD_LIBRARY_PATH # The build image contains cuDNN. Remove its runtime libraries from this disposable # test container so the smoke test proves that the provider works when cuDNN is # physically unavailable, rather than merely relying on enable_cudnn=0. for root in /usr /opt /lib /lib64; do if [ -e "$root" ]; then find "$root" -name "libcudnn*.so*" -print -delete 2>/dev/null || true fi done ldconfig if ldconfig -p | grep -qi cudnn; then echo "cuDNN remains available in the dynamic linker cache" >&2 exit 1 fi if find /usr /opt /lib /lib64 -name "libcudnn*.so*" -print -quit 2>/dev/null | grep -q .; then echo "cuDNN runtime libraries remain in the no-cuDNN test container" >&2 exit 1 fi # Likewise remove cuFFT so the smoke test proves the provider loads and runs # non-FFT operators when cuFFT is physically unavailable (it is loaded lazily and # only needed by the Rfft/Irfft contrib ops). for root in /usr /opt /lib /lib64; do if [ -e "$root" ]; then find "$root" -name "libcufft*.so*" -print -delete 2>/dev/null || true fi done ldconfig if ldconfig -p | grep -qi cufft; then echo "cuFFT remains available in the dynamic linker cache" >&2 exit 1 fi if find /usr /opt /lib /lib64 -name "libcufft*.so*" -print -quit 2>/dev/null | grep -q .; then echo "cuFFT runtime libraries remain in the no-cuDNN test container" >&2 exit 1 fi WHEEL_PATH=$(find /build/Release/Release/dist -type f -name "onnxruntime_gpu-*.whl" | head -n 1) if [ -z "$WHEEL_PATH" ]; then echo "No built onnxruntime GPU wheel found under /build/Release/Release/dist" >&2 exit 1 fi echo "Installing $WHEEL_PATH" python -m pip install --no-cache-dir --force-reinstall --no-deps numpy onnx "$WHEEL_PATH" python - <<"PY" import numpy as np import onnxruntime as ort from onnx import TensorProto, helper providers = [("CUDAExecutionProvider", {"enable_cudnn": "0"})] def run_op(name, model, feeds, expected, rtol=1e-4, atol=1e-4): model.ir_version = 10 options = ort.SessionOptions() options.add_session_config_entry("session.disable_cpu_ep_fallback", "1") sess = ort.InferenceSession(model.SerializeToString(), sess_options=options, providers=providers) got = sess.run(None, feeds)[0] np.testing.assert_allclose(got, expected, rtol=rtol, atol=atol) print("[no-cuDNN] " + name + " passed") def make_model(nodes, inputs, outputs, opset, initializers=None): graph = helper.make_graph(nodes, "no_cudnn_smoke", inputs, outputs, initializer=initializers or []) return helper.make_model(graph, opset_imports=[helper.make_opsetid("", opset)]) def f32_in(shape): return helper.make_tensor_value_info("x", TensorProto.FLOAT, shape) data = np.random.rand(2, 3).astype(np.float32) # Elementwise baseline (does not depend on cuDNN). run_op( "Add", make_model( [helper.make_node("Add", ["x", "x"], ["y"])], [f32_in([2, 3])], [helper.make_tensor_value_info("y", TensorProto.FLOAT, [2, 3])], 21, ), {"x": data}, data + data, ) # LogSoftmax over the last axis (softmax kernel, no cuDNN). shifted = data - data.max(axis=1, keepdims=True) log_softmax = shifted - np.log(np.exp(shifted).sum(axis=1, keepdims=True)) run_op( "LogSoftmax", make_model( [helper.make_node("LogSoftmax", ["x"], ["y"], axis=1)], [f32_in([2, 3])], [helper.make_tensor_value_info("y", TensorProto.FLOAT, [2, 3])], 13, ), {"x": data}, log_softmax, ) # ReduceMean over the last axis (matrix-reduction path, no cuDNN). run_op( "ReduceMean", make_model( [helper.make_node("ReduceMean", ["x"], ["y"], axes=[1], keepdims=1)], [f32_in([2, 3])], [helper.make_tensor_value_info("y", TensorProto.FLOAT, [2, 1])], 13, ), {"x": data}, data.mean(axis=1, keepdims=True), ) # ReduceSum over a middle axis, which requires the general no-cuDNN path. reduce_sum_data = np.random.rand(2, 3, 4).astype(np.float32) run_op( "ReduceSum", make_model( [helper.make_node("ReduceSum", ["x", "axes"], ["y"], keepdims=1)], [f32_in([2, 3, 4])], [helper.make_tensor_value_info("y", TensorProto.FLOAT, [2, 1, 4])], 13, initializers=[helper.make_tensor("axes", TensorProto.INT64, [1], [1])], ), {"x": reduce_sum_data}, reduce_sum_data.sum(axis=1, keepdims=True), ) # ArgMax over the last axis (custom cuDNN-free kernel). run_op( "ArgMax", make_model( [helper.make_node("ArgMax", ["x"], ["y"], axis=1, keepdims=1)], [f32_in([2, 3])], [helper.make_tensor_value_info("y", TensorProto.INT64, [2, 1])], 13, ), {"x": data}, np.argmax(data, axis=1).reshape(2, 1).astype(np.int64), ) # ArgMin over the last axis (custom cuDNN-free kernel). run_op( "ArgMin", make_model( [helper.make_node("ArgMin", ["x"], ["y"], axis=1, keepdims=1)], [f32_in([2, 3])], [helper.make_tensor_value_info("y", TensorProto.INT64, [2, 1])], 13, ), {"x": data}, np.argmin(data, axis=1).reshape(2, 1).astype(np.int64), ) # Rfft requires cuFFT, which was physically removed above. With CPU fallback # disabled the node must run on CUDA and fail cleanly with NOT_IMPLEMENTED # (proving cuFFT is optional and its absence does not crash the provider). rfft_model = helper.make_model( helper.make_graph( [helper.make_node("Rfft", ["x"], ["y"], domain="com.microsoft", signal_ndim=1, onesided=1)], "no_cufft_rfft", [helper.make_tensor_value_info("x", TensorProto.FLOAT, [2, 4])], [helper.make_tensor_value_info("y", TensorProto.FLOAT, [2, 3, 2])], ), opset_imports=[helper.make_opsetid("", 17), helper.make_opsetid("com.microsoft", 1)], ) rfft_model.ir_version = 10 rfft_options = ort.SessionOptions() rfft_options.add_session_config_entry("session.disable_cpu_ep_fallback", "1") try: rfft_sess = ort.InferenceSession( rfft_model.SerializeToString(), sess_options=rfft_options, providers=providers ) rfft_sess.run(None, {"x": np.random.rand(2, 4).astype(np.float32)}) except Exception as exc: # noqa: BLE001 message = str(exc).lower() assert "cufft" in message, "Rfft without cuFFT raised an unexpected error: " + str(exc) print("[no-cuFFT] Rfft correctly failed: " + str(exc).splitlines()[0]) else: raise AssertionError("Rfft unexpectedly succeeded while cuFFT was unavailable") print("CUDA no-cuDNN/no-cuFFT op smoke tests passed") PY'