Which setup are you referring to?
If you need to install the Yamaha USB-MIDI driver, make sure you download the correct version, then connect the keyboard to the computer and turn it on before you try to install the driver, then install the driver and it should be able to detect the keyboard and set itself up for that model.
If you need to install the Steinberg USB driver, which is the correct driver for Yamaha models that have a built-in USB audio interface, you must do the installation in the opposite order-- make sure the keyboard is not connected to the computer, then install the driver, then connect the keyboard to the computer and turn it on.
If you have software that you want to use the keyboard with-- a DAW or other MIDI editor, the Yamaha Musicsoft Downloader, Playground Sessions, etc.-- then I think in general it shouldn't matter whether you install the driver for your keyboard before or after running the setup for the other software, because most software of that nature is designed to work with several makes and models of MIDI devices, hence they should allow for the possibility of adding more devices to your gear setup after they've already been installed, rather than requiring you to uninstall the software, install your new gear, and reinstall the software each time you get a new piece of gear.
However, if you're talking about software that's designed to work with only a select number of devices, you should check the installation instructions for that software to see what the proper installation procedure is.