openai gym是RL算法的測試牀。爲了直觀和便於調試,咱們須要可視化界面。然而遠程服務器使用openGL的問題比較棘手,這篇博客記錄在百度雲BCC上配置openai gym環境的注意事項。html
按照gym的指示,須要用python
xvfb-run -s "-screen 0 1400x900x24" bash 來建立fake displaygit
然而,運行到env.render()時會有這樣的問題:pyglet requires an X server with GLXgithub
也就是說,咱們的openGL沒有GLX擴展算法
if the Nvidia proprietary driver (e.g. 340.93) is installed, our OpenGL apps fail to create an OpenGL context when using Xvfb's display. The very same happens to glxinfo and glxgears in this scenariobash
gym裏這個issue的解決方案給了很好的提示:nvidia的顯卡驅動要 --no-opengl-files , CUDA要 --no-opengl-libs服務器
因此要重裝nvidia顯卡驅動,以下所示app
能夠參考一個很詳細的步驟:測試
https://davidsanwald.github.io/2016/11/13/building-tensorflow-with-gpu-support.htmlui
注意安裝CUDA的時候選擇
安裝成功以後,運行demo不會報錯
再安裝gnome桌面環境和vnc4server,遠程鏈接後就能夠有圖像顯示了
運行時,
xvfb-run -a -s "-screen 0 1400x900x24 +extension RANDR" -- -python test.py
或
xvfb-run -s "-screen 0 1400x900x24" bash
glxinfo查看glx信息
vnc4server建立新的端口
參考:
https://github.com/openai/gym/issues/384
https://davidsanwald.github.io/2016/11/13/building-tensorflow-with-gpu-support.html
https://github.com/openai/gym/issues/347
https://github.com/2017-fall-DL-training-program/Setup_tutorial/blob/master/OpenAI-gym-install.md