you have to learn how the intervals relate by their position, for example, the octave is two frets higher and two strings apart...
_______6_______
_______________
_______4_______
except for the three last strings... but that's a starting point... Then, learn the third major/minor (respectively a fret/two frets lower on the higher adjacent string...) etc... You'll visualize your fretboard, and learn the names of the notes in the process...
I hope I was clear enough!!