参考链接:https://askubuntu.com/questions/927199/nvidia-smi-has-failed-because-it-couldnt-communicate-with-the-nvidia-driver-ma
command prime-select
to check available choice for gpu setting
command prime-select nvidia
to choose nvidia dedicated gpu
command prime-select intel
to choose intel integrated gpu
reboot and it should work.