File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 33
33
34
34
namespace tensorpipe {
35
35
36
+ class NoDevicesError final : public BaseError {
37
+ public:
38
+ std::string what () const override {
39
+ return " The CUDA driver failed to init because it didn't find any device" ;
40
+ }
41
+ };
42
+
36
43
// Master list of all symbols we care about from libcuda.
37
44
38
45
#define TP_FORALL_CUDA_SYMBOLS (_ ) \
@@ -114,7 +121,14 @@ class CudaLib {
114
121
}
115
122
TP_FORALL_CUDA_SYMBOLS (TP_LOAD_SYMBOL)
116
123
#undef TP_LOAD_SYMBOL
117
- TP_CUDA_DRIVER_CHECK (lib, lib.init (0 ));
124
+ CUresult result = lib.init (0 );
125
+ // If the driver doesn't find any devices it fails to init (beats me why)
126
+ // but we must support this case, by disabling the channels, rather than
127
+ // throwing. Hence we treat it as if we couldn't find the driver.
128
+ if (result == CUDA_ERROR_NO_DEVICE) {
129
+ return std::make_tuple (TP_CREATE_ERROR (NoDevicesError), CudaLib ());
130
+ }
131
+ TP_CUDA_DRIVER_CHECK (lib, result);
118
132
return std::make_tuple (Error::kSuccess , std::move (lib));
119
133
}
120
134
You can’t perform that action at this time.
0 commit comments