Repository navigation
Fix GPU nodes failing to start when the CUDA driver is newer than the installed toolkit #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
df97c37
a4d16e1
dac1019
946311b
8219371
0b8c90f
2747512
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,24 +304,73 @@ fn detect_cuda_profile(gpus: &[HostGpuProfile]) -> Option<HostCudaProfile> { | |
| toolkit_majors.insert(major); | ||
| } | ||
| if toolkit_majors.is_empty() { | ||
| toolkit_majors.extend(cuda_majors_from_nvidia_smi()); | ||
| toolkit_majors.extend(installed_cuda_toolkit_majors()); | ||
| } | ||
| // `nvidia-smi` reports the newest CUDA the driver supports, which is often | ||
| // ahead of the installed toolkit. Keep it separate so it is only used as an | ||
| // upper bound during runtime selection. | ||
| let driver_max_major = env_u32("MESH_LLM_CUDA_DRIVER_MAX_MAJOR") | ||
| .or_else(|| cuda_majors_from_nvidia_smi().into_iter().next_back()); | ||
| let mut gpu_arches = env_string_set("MESH_LLM_CUDA_GPU_ARCHES"); | ||
| gpu_arches.extend(gpus.iter().filter_map(|gpu| gpu.cuda_sm.clone())); | ||
| let has_cuda_label = gpus.iter().any(|gpu| { | ||
| let label = gpu.display_name.to_ascii_lowercase(); | ||
| label.contains("nvidia") || label.contains("cuda") | ||
| }); | ||
| if toolkit_majors.is_empty() && gpu_arches.is_empty() && !has_cuda_label { | ||
| if toolkit_majors.is_empty() | ||
| && driver_max_major.is_none() | ||
| && gpu_arches.is_empty() | ||
| && !has_cuda_label | ||
| { | ||
| return None; | ||
| } | ||
| Some(HostCudaProfile { | ||
| toolkit_majors, | ||
| driver_max_major, | ||
| driver_version: std::env::var("MESH_LLM_CUDA_DRIVER_VERSION").ok(), | ||
| gpu_arches, | ||
| }) | ||
| } | ||
|
|
||
| /// CUDA toolkit majors with runtime libraries actually present on this host. | ||
| /// | ||
| /// Linux native runtimes link against `libcudart.so.<major>` without bundling | ||
| /// it, so this is the set that can really be loaded. Windows runtimes ship | ||
| /// their own copies and do not depend on this. | ||
| fn installed_cuda_toolkit_majors() -> BTreeSet<u32> { | ||
| let mut majors = BTreeSet::new(); | ||
| if let Some(output) = command_output("ldconfig", &["-p"]) { | ||
| majors.extend(cuda_majors_from_soname_listing(&output)); | ||
| } | ||
| for base in ["/usr/local/cuda", "/usr/local"] { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify runtime libraries, not just the toolkit directory name. A |
||
| let Ok(entries) = std::fs::read_dir(base) else { | ||
| continue; | ||
| }; | ||
| for entry in entries.flatten() { | ||
| let name = entry.file_name().to_string_lossy().to_string(); | ||
| if let Some(rest) = name.strip_prefix("cuda-") | ||
| && let Some(major) = leading_major_version(rest) | ||
| { | ||
| majors.insert(major); | ||
| } | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| majors | ||
| } | ||
|
|
||
| /// Extract CUDA majors from `libcudart.so.<major>` sonames in a listing. | ||
| fn cuda_majors_from_soname_listing(output: &str) -> BTreeSet<u32> { | ||
| let mut majors = BTreeSet::new(); | ||
| for token in output.split_whitespace() { | ||
| if let Some(rest) = token.strip_prefix("libcudart.so.") | ||
| && let Some(major) = leading_major_version(rest) | ||
| { | ||
| majors.insert(major); | ||
| } | ||
| } | ||
| majors | ||
| } | ||
|
|
||
| fn detect_rocm_profile(gpus: &[HostGpuProfile]) -> Option<HostRocmProfile> { | ||
| let mut gpu_arches = env_string_set("MESH_LLM_ROCM_GPU_ARCHES"); | ||
| gpu_arches.extend(rocm::gpu_arches()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,16 @@ pub struct HostGpuProfile { | |
|
|
||
| #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] | ||
| pub struct HostCudaProfile { | ||
| /// CUDA toolkit majors whose runtime libraries are actually installed on | ||
| /// this host (for example `libcudart.so.12`). A runtime that does not ship | ||
| /// its own CUDA libraries can only load if its major appears here. | ||
| #[serde(default)] | ||
| pub toolkit_majors: BTreeSet<u32>, | ||
| /// Highest CUDA major the installed driver supports, as reported by | ||
| /// `nvidia-smi`. This is an upper bound, not evidence that a matching | ||
| /// toolkit is installed. | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub driver_max_major: Option<u32>, | ||
|
Comment on lines
+38
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Update the Line 42 adds a required struct field. The example in 🤖 Prompt for AI Agents |
||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub driver_version: Option<String>, | ||
| #[serde(default)] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Probe configured CUDA library roots too.
ldconfig -pplus/usr/local/cuda-*misses toolkits installed under a custom prefix or exposed only throughLD_LIBRARY_PATH/CUDA_HOME(for example Conda or/opt/cuda-12). On a host withlibcudart.so.12in one of those paths and a driver advertising CUDA 13,toolkit_majorsstays empty and the resolver falls back to selecting cuda13—the load failure this PR is intended to prevent. Please include the loader/environment search paths (with the same complete-library validation) or explicitly handle this installation shape.