Caffe2 - C++ API
A deep learning, cross platform ML framework
cuda.cpp
1 #include <torch/cuda.h>
2 
3 #include <ATen/Context.h>
4 
5 #include <cstddef>
6 
7 namespace torch {
8 namespace cuda {
9 size_t device_count() {
10  return at::detail::getCUDAHooks().getNumGPUs();
11 }
12 
13 bool is_available() {
14  // NB: the semantics of this are different from at::globalContext().hasCUDA();
15  // ATen's function tells you if you have a working driver and CUDA build,
16  // whereas this function also tells you if you actually have any GPUs.
17  return cuda::device_count() > 0;
18 }
19 
20 bool cudnn_is_available() {
21  return is_available() && at::detail::getCUDAHooks().hasCuDNN();
22 }
23 } // namespace cuda
24 } // namespace torch
Definition: jit_type.h:17