|
172 | 172 | else |
173 | 173 | cudaDriverDir = eessi_eprefix .. "/lib/nvidia" |
174 | 174 | end |
175 | | - local cudaVersionFile = cudaDriverDir .. "/cuda_version.txt" |
176 | 175 | local cudaDriverFile = cudaDriverDir .. "/libcuda.so" |
177 | 176 | local cudaDriverExists = isFile(cudaDriverFile) |
178 | 177 | local singularityCudaExists = isFile("/.singularity.d/libs/libcuda.so") |
|
189 | 188 | else |
190 | 189 | -- CUDA driver exists, now we check its version to see if an update is needed |
191 | 190 | if cudaDriverExists then |
192 | | - local cudaVersion = read_file(cudaVersionFile) |
193 | | - if not cudaVersion then |
194 | | - LmodError("No CUDA version file\\n" .. cudaVersionFile .. "\\nfound. " .. refer_to_docs) |
| 191 | + local cudaVersion = os.getenv("EESSI_CUDA_DRIVER_VERSION") |
| 192 | + if not cudaVersion or cudaVersion == "" then |
| 193 | + local eessi_prefix = os.getenv("EESSI_PREFIX") |
| 194 | + local script = pathJoin(eessi_prefix, 'scripts', 'gpu_support', 'nvidia', 'get_cuda_driver_version.sh') |
| 195 | + source_sh("bash", script) |
195 | 196 | end |
| 197 | + cudaVersion = os.getenv("EESSI_CUDA_DRIVER_VERSION") |
196 | 198 | local cudaVersion_req = os.getenv("EESSICUDAVERSION") |
197 | | - -- driver CUDA versions don't give a patch version for CUDA |
198 | | - local major, minor = string.match(cudaVersion, "(%d+)%.(%d+)") |
199 | | - local major_req, minor_req, patch_req = string.match(cudaVersion_req, "(%d+)%.(%d+)%.(%d+)") |
200 | | - local driver_libs_need_update = false |
201 | | - if major < major_req then |
202 | | - driver_libs_need_update = true |
203 | | - elseif major == major_req then |
204 | | - if minor < minor_req then |
| 199 | + -- Account for the fact that the script sourced above was designed to never return a non-zero exit |
| 200 | + -- even if it fails to set EESSI_CUDA_DRIVER_VERSION |
| 201 | + -- Essentially, we handle that case here by raising an error, which can be suppressed |
| 202 | + if not cudaVersion or cudaVersion == "" then |
| 203 | + local suppress_var = "EESSI_CUDA_DRIVER_VERSION_SUPPRESS_WARNING" |
| 204 | + local warn = "Environment variable EESSI_CUDA_DRIVER_VERSION not found. " |
| 205 | + warn = warn .. "Cannot ensure that driver version is new enough for CUDA toolkit version: '" |
| 206 | + warn = warn .. cudaVersion_req .. "'. This module will still be loaded, but may not function " |
| 207 | + warn = warn .. "as expected. Export " .. suppress_var .. "=1" |
| 208 | + local suppress_warn = os.getenv(suppress_var) |
| 209 | + if not suppress_warn or suppress_warn == 1 then |
| 210 | + LmodWarning(warn) |
| 211 | + end |
| 212 | + else |
| 213 | + -- driver CUDA versions don't give a patch version for CUDA |
| 214 | + local major, minor = string.match(cudaVersion, "(%d+)%.(%d+)") |
| 215 | + local major_req, minor_req, patch_req = string.match(cudaVersion_req, "(%d+)%.(%d+)%.(%d+)") |
| 216 | + local driver_libs_need_update = false |
| 217 | + if tonumber(major) < tonumber(major_req) then |
205 | 218 | driver_libs_need_update = true |
| 219 | + elseif tonumber(major) == tonumber(major_req) then |
| 220 | + if tonumber(minor) < tonumber(minor_req) then |
| 221 | + driver_libs_need_update = true |
| 222 | + end |
| 223 | + end |
| 224 | + if driver_libs_need_update == true then |
| 225 | + local advice = "but the module you want to load requires CUDA " .. cudaVersion_req .. ". " |
| 226 | + advice = advice .. "Please update your CUDA driver libraries and then " |
| 227 | + advice = advice .. "let EESSI know about the update.\\n" |
| 228 | + advice = advice .. refer_to_docs |
| 229 | + LmodError("\\nYour driver CUDA version is ", cudaVersion, " ", advice) |
206 | 230 | end |
207 | | - end |
208 | | - if driver_libs_need_update == true then |
209 | | - local advice = "but the module you want to load requires CUDA " .. cudaVersion_req .. ". " |
210 | | - advice = advice .. "Please update your CUDA driver libraries and then " |
211 | | - advice = advice .. "let EESSI know about the update.\\n" |
212 | | - advice = advice .. refer_to_docs |
213 | | - LmodError("\\nYour driver CUDA version is ", cudaVersion, " ", advice) |
214 | 231 | end |
215 | 232 | end |
216 | 233 | end |
|
0 commit comments