Updated build script for CUDA case (#20987)

### Description

In CUDA case, use the cuda_home variable to set CMAKE's CUDA compiler to
a correct version of NVCC

Otherwise, an NVCC from a current PATH would be picked up, which could
be from a different version of CUDA.


### Motivation and Context

I had a case when I had main CUDA installed, and it was a version 11.8.

I wanted to build against 12.5, so I downloaded and unpacked it into a
separate directory and passed it as a `--cuda-home` parameter, however
the ONNX builder was still picking the NVCC compiler from 11.8.

This would fix the issue
https://github.com/microsoft/onnxruntime/issues/20928


cc @gedoensmax
This commit is contained in:
Nikolai Svakhin 2024-06-17 14:41:43 -07:00 committed by GitHub
parent a6c18ae9df
commit 7b3fff650a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1158,6 +1158,7 @@ def generate_build_tree(
f"Float 8 types require CUDA>=11.8. They must be disabled on CUDA=={args.cuda_version}. "
f"Add '--disable_types float8' to your command line. See option disable_types."
)
cmake_args.append(f"-DCMAKE_CUDA_COMPILER={cuda_home}/bin/nvcc")
if args.use_rocm:
cmake_args.append("-Donnxruntime_ROCM_HOME=" + rocm_home)
cmake_args.append("-Donnxruntime_ROCM_VERSION=" + args.rocm_version)