How can you play Steam games with nvidia-optimus laptop?

What is the best way to start a Steam game on a NVIDIA Optimus laptop with Ubuntu 12.04 installed and the latest version of bumblebee installed?

If I call Steam with optirun steam and then choose the game I want to play, I get the following error:

The program 'hl2_linux' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
  (Details: serial 125 error_code 9 request_code 14 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Missing shutdown function for DevShotGenerator_Init() : DevShotGenerator_Shutdown()
Missing shutdown function for MapReslistGenerator_Init() : MapReslistGenerator_Shutdown()
Missing shutdown function for COM_InitFilesystem( m_StartupInfo.m_pInitialMod ) : COM_ShutdownFileSystem()
Missing shutdown function for Steam3Client().Activate() : Steam3Client().Shutdown()
/home/user/.local/share/Steam/SteamApps/user/Team Fortress 2/hl2.sh: line 72: 20567 Segmentation fault      (core dumped) ${GAME_DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"
Game removed: AppID 440 "Team Fortress 2", ProcID 20567 
saving roaming config store to 'sharedconfig.vdf'
roaming config store 2 saved successfully
^C[68042.116376] [WARN]Received Interrupt signal.

If I run steam without the optirun option, I can go a little further into running the game, hearing the starting music on a black screen, but still fails later on in the process.

Should I call the game I want to play with a special optirun command instead of optirun steam?


Check these links - You need to change game properties as shown below

  • Right click on TF2 in your library
  • Click Properties
  • Click Set Launch Options
  • If you only have optirun, enter: optirun %command%

The above did not work for me and I had to set the launch options as

LD_PRELOAD="libpthread.so.0 libGL.so.1" __GL_THREADED_OPTIMIZATIONS=1 optirun %command% 

Check these discussions:

  • http://steamcommunity.com/groups/LinuxOptimus/discussions/0/846944052733804503/
  • http://steamcommunity.com/groups/LinuxOptimus/discussions/1/864951657810665792/

If this does not work download the hl2-optirun.sh to below location and run it.

/home/user/Steam/SteamApps/'account_name'/Team Fortress 2/

Valve recommends using primusrun for running Steam games on the NVIDIA GPU.

See the following guide for help on doing so:

https://support.steampowered.com/kb_article.php?ref=6316-GJKC-7437