You have to allow non-free packages in /etc/sources.list likw so:
Code:
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch main contrib non-free
and then uninstall everything nvidia:
Code:
$ apt-get purge nvidia*
and then install te correct driver:
Code:
$ apt-get install nvidia-legacy-340xx-driver
You can refer to this gem from my heart to every noob:
https://wiki.debian.org/DontBreakDebian