Skip to content

Commit

Permalink
Now disabling CUDA for any error during the cuInit() like when an ext…
Browse files Browse the repository at this point in the history
…ernal GPU is unplugged (issue #493)
  • Loading branch information
Dade916 committed Jan 11, 2021
1 parent e738b05 commit 815391d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Beta1 released
* Fixed a discrepancy in reflected area lights on glossy surfaces between CPU and GPU rendering when light tracing is enabled (issue #470)
* Avoid to return CUDA_ERROR_NO_DEVICE error if CUDA is installed but there are no NVIDIA GPUs installed
* Fixed compilation when CUDA is disabled but OpenCL is still enabled
* Now disabling CUDA for any error during the cuInit() like when an external GPU is unplugged (issue #493)

Check https://wiki.luxcorerender.org/LuxCoreRender_Release_Notes for the full list
of release notes.
Expand Down
16 changes: 10 additions & 6 deletions src/luxrays/core/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ void Init() {
#endif

#if !defined(LUXRAYS_DISABLE_CUDA)
if (cuewInit(CUEW_INIT_CUDA|CUEW_INIT_NVRTC) == CUEW_SUCCESS) {
if (cuewInit(CUEW_INIT_CUDA | CUEW_INIT_NVRTC) == CUEW_SUCCESS) {
// Was:
//CHECK_CUDA_ERROR(cuInit(0));

const CUresult err = cuInit(0);
if (err == CUDA_ERROR_NO_DEVICE) {
// This handles the case when CUDA is installed but there are no
// NVIDIA GPUs installed.
if (err != CUDA_SUCCESS) {
// Handling multiple cases like:
//
// - when CUDA is installed but there are no NVIDIA GPUs available (CUDA_ERROR_NO_DEVICE)
//
// - when CUDA is installed but there an external GPU is unplugged (CUDA_ERROR_UNKNOWN)
//
// In all above cases, I just disable CUDA (but with this solution, at
/// the moment I have no way to report the type of error).
} else {
CHECK_CUDA_ERROR(err);

isCudaAvilable = true;

// Try to initialize Optix too
Expand Down

0 comments on commit 815391d

Please sign in to comment.