Namespace "at::cuda" has no member "is_available"

Using 1.6:

What is the catch? It’s working in python.

Maybe you need to include the CUDAContext.h header.
Note that it is a function, not a variable, so you’re missing the ().

In general, I would recommend to just put the function name you’re looking for into the C++ doc search box if you cannot find something from Python to find the right headers. (Which is not to say you should have done it this time, but to help you solve problems in the future.)

Best regards


That was just a typo, it works under CMake, not under VC 19.


I have a question regarding CUDA compatibility. I have installed cuda toolkit with PyTorch 1.6 that I installed through anaconda for python development.

So I wanted to ask you if I can link that cuda with the C++ library? Because I don’t have CUDA installed on the machine, just in the environment.

Yes, PyTorch distributions contain the full libtorch, so you can use that. (I’m not sure they come with all cuda headers, there might be ones they only use indirectly.)

So I am facing this. I don’t have CUDA installed. So what should I do to get rid of this error?