Skip to content

Commit b13b701

Browse files
authored
check for nvidia driver's sufficiency before checking for number of CUDA devices (pytorch#1156)
1 parent 5c79046 commit b13b701

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

torch/csrc/autograd/engine.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,14 @@ auto Engine::ready_queue(int device) -> ReadyQueue& {
350350
auto Engine::start_threads() -> void {
351351
int num_devices = 0;
352352
#ifdef WITH_CUDA
353-
THCudaCheck(cudaGetDeviceCount(&num_devices));
353+
cudaError_t err = cudaGetDeviceCount(&num_devices);
354+
355+
// check for case of compiled with CUDA but no NVIDIA driver available
356+
if (err == cudaErrorInsufficientDriver) {
357+
num_devices = 0;
358+
} else {
359+
THCudaCheck(err);
360+
}
354361
#endif
355362
ready_queues = std::vector<std::unique_ptr<ReadyQueue>>(num_devices + 1);
356363
for (auto& queue : ready_queues) {

0 commit comments

Comments
 (0)