I am trying to compile the example app described at cpp installation docs 49 with GPU support.
I changed the download link to https://download.pytorch.org/libtorch/cu90/libtorch-shared-with-deps-latest.zip and the program to:
int main() {
  torch::Tensor tensor = torch::randn({3, 4}, torch::dtype(torch::kFloat32).device(torch::kCUDA, 1).requires_grad(true));
  std::cout << tensor << std::endl;
}

It compiles fine, but when executing I have the following error:
terminate called after throwing an instance of 'c10::Error'
  what():  p ASSERT FAILED at /home/dani/libtorch/include/c10/impl/DeviceGuardImplInterface.h:125, please report a bug to PyTorch. DeviceGuardImpl for cuda is not available (getDeviceGuardImpl at /home/dani/libtorch/include/c10/impl/DeviceGuardImplInterface.h:125)
frame #0: std::function<std::string ()>::operator()() const + 0x11 (0x7f2360b7cfe1 in /home/dani/libtorch/lib/libc10.so)
frame #1: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x2a (0x7f2360b7cdfa in /home/dani/libtorch/lib/libc10.so)
frame #2: c10::impl::getDeviceGuardImpl(c10::DeviceType) + 0xe8 (0x40e288 in ./example-app)
frame #3: c10::impl::VirtualGuardImpl::VirtualGuardImpl(c10::DeviceType) + 0x36 (0x40e3b6 in ./example-app)
frame #4: c10::impl::InlineDeviceGuard<c10::impl::VirtualGuardImpl>::InlineDeviceGuard(c10::Device) + 0x2c (0x410844 in ./example-app)
frame #5: c10::DeviceGuard::DeviceGuard(c10::Device) + 0x20 (0x40e56c in ./example-app)
frame #6: ./example-app() [0x40cea0]
frame #7: torch::randn(c10::ArrayRef<long>, at::TensorOptions const&) + 0x1fb (0x40f99e in ./example-app)
frame #8: main + 0xf1 (0x40d246 in ./example-app)
frame #9: __libc_start_main + 0xf0 (0x7f2360228830 in /lib/x86_64-linux-gnu/libc.so.6)
frame #10: _start + 0x29 (0x40ca59 in ./example-app)

I am on Ubuntu and I have cuda 9.0 and cudnn 7 installed and I was able to fully compile pytorch from source on the same machine.
Any ideas?