diff options
Diffstat (limited to 'cuda/3d/darthelper3d.cu')
-rw-r--r-- | cuda/3d/darthelper3d.cu | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cuda/3d/darthelper3d.cu b/cuda/3d/darthelper3d.cu index 68330a1..6e60ec2 100644 --- a/cuda/3d/darthelper3d.cu +++ b/cuda/3d/darthelper3d.cu @@ -215,12 +215,14 @@ namespace astraCUDA3d { bool setGPUIndex(int iGPUIndex) { - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } return true; } |