black screen after installing nvidia driver on Linux Mint 19.1

I wanted to install OpenGL libraries with nouveau driver. But when I compile my C++ code it gived me the error that GL shared library couldn’t be found. I’ve asked about it here, but with no success. I decided to install Nvidia driver from Driver Manager and after reboot I get black screen after logo splash. I’m able to login with Ctrl+Alt+F1 and ‘startx’. In that way I compiled my code and when running get this error

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  29
  Current serial number in output stream:  30

please help me fix this issue. I don’t know what information exactly to attach here, so you’re welcome to request some additional info.
nvidia-bug-report.log.gz (70 KB)

Please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post of yours will reveal a paperclip icon.
[url]https://devtalk.nvidia.com/default/topic/1043347/announcements/attaching-files-to-forum-topics-posts/[/url]

i attached bug report file and i had this message when ran it

Running nvidia-bug-report.sh...ls: cannot access '/proc/driver/nvidia/./gpus/': No such file or directory

If the bug report script hangs after this point consider running with
--safe-mode command line argument.

modprobe: ERROR: could not insert 'nvidia': No such device
Killed
 complete.

and also i did it after choosing nvidia-340 driver in driver manager but not rebooted yet. because after reboot i have black screen. or do i need to run bug-report after reboot?

now i rebooted and from black screen i opened tty1 and ran bug report. but after manual startx it says
that “Cinnamon just crashed. You are currently running in Fallback Mode. Do you want to restart
Cinnamon?” and asks to unlock login keyring
nvidia-bug-report.log.gz (107 KB)

Please make sure that the package nvidia-prime is installed, reinstall it using
sudo apt-get --reinstall nvidia-prime
Please post the version that gets installed. Afterwards, check that the file /usr/share/lightdm/lightdm.conf.d/90-nvidia.conf exists. Run
sudo prime-select nvidia
and reboot.

after installing nvidia-prime i installed nvidia-340 from driver manager. and after reboot everything works fine. i got that its optimus so after i installed bumblbee and rebooted cinnamo crashed in fallback mode. where to refer or do i need to start a new thread for it, because i solved my initial problem stated on title.

Bumblebee and nvidia-prime are mutual exclusives, you can only have one of them installed, otherwise you’ll get a non-working system.

so how can i manage to run applications with dGPU like i could do it as

primus appname

. with nvidia x settings i can change between gpus only after logging out and in