The following worked for me. With error message:
error: Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice
Firstly I searched for nvvm directory and then verified that libdevice directory existed:
$ find / -type d -name nvvm 2>/dev/null
/usr/lib/cuda/nvvm
$ cd /usr/lib/cuda/nvvm
/usr/lib/cuda/nvvm$ ls
libdevice
/usr/lib/cuda/nvvm$ cd libdevice
/usr/lib/cuda/nvvm/libdevice$ ls
libdevice.10.bc
Then I exported the environment variable:
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/lib/cuda
as shown by @Insectatorious above. This solved the error and I was able to run the code.