How to make CUDA work in Ubuntu so as to enable GPU rendering in Blender?
After long trying I could solve this problem

I found out that my NVIDIA card was not being recognized by the NVIDIA driver I had installed. So NVIDIA X server settings was "empty" like in this thread: https://ubuntuforums.org/showthread.php?t=2342538 but it was recognized by Ubuntu, what I could see by entering the command lspci -nn | grep '\[03' in terminal and getting PCI info about the "3D Controller".

But if I ran prime-select query in terminal I was getting unknown. My Laptop has a NVIDIA and an Intel card and I thought NVIDIA was working because I had graphical acceleration, but I think it was the whole time using the Intel controller. Tried to change the output by typing sudo prime-select nvidia and then I got nvidia by checking prime-select again. But if I restarted the system it was again unknown and nvidia-settings remained empty. I followed all helps I found in forums or stackexchange posts and my problem wasn't solved.

The solution that worked for me was uninstalling NVIDIA drives completely (did this several times) and installing nvidia drivers in a specific order:
First Ctrl+Alt+F1 to enter the tty and then:

sudo service lightdm stop # to kill the user interface process
sudo apt purge nvidia-* # to remove all nvidia packages
sudo dpkg --get-selections | grep nvidia # check that no nvidia packages remain
sudo add-apt-repository ppa:graphics-drivers/ppa # if you still didn't add it
sudo apt update
sudo apt install nvidia-375 # installed the NVIDIA drivers v.375.66
sudo apt install nvidia-prime nvidia-settings # Probably already installed
sudo apt install nvidia-cuda-toolkit # if you want to use CUDA
sudo apt install nvidia-modprobe


when restarting I disabled IEFI secure boot in the secure boot blue screen. After doing everything the NVIDIA card was not recognized yet. So I went to the tab "additional drivers" on the software-properties-gtk (just type this in terminal to open) and selected the driver Nvidia version 340.102 (proprietary) and clicked apply changes. After rebooting the machine again the card was recognized by NVIDIA X server settings (or nvidia-settings) and everything worked fine, Blender recognized CUDA and so on. I just don't understand why NVIDIA put my GeForce GTX 760M in the list of supported cards for the drivers version 340, 375 and so on, but actually just one (or some) of them works, in my case this (older?) version nvidia-340. I had already tried to install nvidia-340 directly from the repository and also select it in additional drivers without previous installation. It should have worked, but it hasn't.

Conclusions: the nvidia drivers for Linux are there, but it's a huge mess! Ubuntu does its job fine by recognizing it with the command List PCI lspci, but the nvidia support is messy and unclear with this several versions. So, if you still have problems on making your card work, try to install different propietary driver versions or select them from the additional drivers list. Maybe the driver you tried to use is actually not the one that works with your graphics card. Let's see if NVIDIA decides to make that better and start to opensource their drivers!