Commit 778d420
Fix CUDA GPU detection crash when running with device=cpu on machines without GPU (#6759)
* Initial plan
* Fix CUDA GPU detection when device is set to CPU
- Add runtime check for PARAM.inp.device before calling GPU detection functions
- Prevent cudaErrcheck from exiting when no GPU is available but device is set to "cpu"
- Apply same logic as non-MPI version to MPI version in output_device_info
Co-authored-by: dzzz2001 <153698752+dzzz2001@users.noreply.github.com>
* Implement device=auto with safe GPU probe and MPI broadcast
- Add probe_gpu_availability() function that safely checks GPU without exiting
- Refactor get_device_flag() to support device=auto with clear user feedback
- Implement MPI broadcast for consistent device selection across all ranks
- Add safety check in get_device_kpar() to prevent GPU calls when unavailable
- Add informative messages for device selection (INFO/WARNING)
Co-authored-by: dzzz2001 <153698752+dzzz2001@users.noreply.github.com>
* Fix MPI synchronization issue in get_device_kpar
- Remove redundant probe_gpu_availability check that could cause MPI inconsistency
- Function is only called when device=gpu is already confirmed
- Add comment clarifying the function should only be called in GPU mode
Co-authored-by: dzzz2001 <153698752+dzzz2001@users.noreply.github.com>
* 注释掉 get_device_flag 中所有 std::cout 输出,避免冗余信息打印
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dzzz2001 <153698752+dzzz2001@users.noreply.github.com>
Co-authored-by: dzzz2001 <dzcpku2001@163.com>1 parent 6b96629 commit 778d420
File tree
3 files changed
+86
-51
lines changed- source/source_base/module_device
3 files changed
+86
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 149 | + | |
165 | 150 | | |
166 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
167 | 158 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
174 | 168 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 169 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 170 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
197 | 212 | | |
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
201 | 216 | | |
| 217 | + | |
| 218 | + | |
202 | 219 | | |
203 | 220 | | |
204 | 221 | | |
| |||
213 | 230 | | |
214 | 231 | | |
215 | 232 | | |
216 | | - | |
217 | | - | |
| 233 | + | |
| 234 | + | |
218 | 235 | | |
219 | | - | |
220 | | - | |
| 236 | + | |
| 237 | + | |
221 | 238 | | |
222 | | - | |
| 239 | + | |
223 | 240 | | |
224 | | - | |
| 241 | + | |
225 | 242 | | |
226 | 243 | | |
227 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
119 | 125 | | |
120 | 126 | | |
121 | 127 | | |
| |||
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
136 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
| |||
0 commit comments