Cannot connect to X server GOOGLE COLAB

自作多情 提交于 2019-12-01 20:47:00

An X server is a program in the X Window System that runs on local machines (i.e. the computers used directly by users) and handles all access to the graphics cards, display screens and input devices (typically a keyboard and mouse) on those computers.

With that said Colab runs as a terminal instance in the server, if you are using GPU runtime, then the problem is not with X server accessing your Graphics card, neither with Input devices, generally this occurs when you try to parse some data that should be displayed as separate window on your desktop, commands like cv2.imshow(), there can be other similar functions that can cause this problem, if you have to use graphical ouput you might want to look into %matplotlib notebook and displaying the data in the interactable matplot plots.

If this is not your issue, just post a link to your modified code and I might be able to help more.

I had the same problem in Colab for a simple OpenCV program to track a tennis ball in a tennis match video and had to comment out these lines, as mentioned by @anand:

#cv2.namedWindow("motion")
#cv2.imshow("motion", img)# モーション画像を表示 

#cv2.destroyAllWindows()

Note: the above lines were not clustered but spread apart.

I could fix this issue by using below python code in Google Colab note

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!