linux系统下:环境主体为tensorflow1.7.0, python3.5以及其他相关安装包
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.5
sudo apt-get install python3-pip
关于opencv:
pip3 install opencv-python
pip3 install opencv-contrib-python -i https://pypi.douban.com/simple
关于远程连接X11-Xmanager的各种问题:
1、
sudo apt-get install vim
vim /etc/ssh/sshd_config
2、下载安装Xmanager6
新建XDMCP会话框:ssh远程连接
新建Xstart会话框:填写主机,用户及密码之后
3、qt方面的报错:
qt.qpa.xcb: could not connect to display 139.198.17.14:0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.6/dist-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
Aborted (core dumped)
cd /usr/local/lib/python3.6/dist-packages/cv2/qt/plugins/platforms
ldd libqxcb.so
可以得到类似:
若其中出现
libSM.so.6 not found
libICE.so.6 not found
apt-get update && apt install -y libsm6 libxext6
apt-get install -y libxrender-dev
apt-get install libsm6 libxrender1 libfontconfig1
4、
echo $DISPLAY
#若无输出,则执行以下命令
vim /etc/profile
#在文件最后一行添加
export DISPLAY=localhost:0.0
xhost +
#若无输出,则执行以下命令
sudo apt-get update -y
sudo apt-get install -y x11-xserver-utils
Docker容器通过X11转发显示图形界面
运行docker时加入以下参数
docker run -it \
-v /etc/localtime:/etc/localtime:ro \
--net=host \
-e DISPLAY=:10.0 \
-v $HOME/slides:/root/slides \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name [containername] \
[yourimage] \
/bin/bash
并且在docker宿主机关闭X11验证
sudo vim /etc/lightdm/lightdm.conf
#增加 xserver-allow-tcp=true
sudo systemctl restart lightdm
xhost + #每次重新开机后都要运行
docker运行GUI软件:
1、
#在主系统里运行
sudo apt-get install x11-xserver-utils
xhost +
#启动docker容器时添加:
-v /tmp/.X11-unix:/tmp/.X11-unix \ #共享本地unix端口
-e DISPLAY=unix$DISPLAY \ #修改环境变量DISPLAY
-e GDK_SCALE \ #我觉得这两个是与显示效果相关的环境变量,没有细究
-e GDK_DPI_SCALE \
#最后完整的启动命令为:
$ docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name libreoffice \
jess/libreoffice
#每次重新开机时需要在本机操作一次
xhost +
2、
#使用ifconfig查看主机和docker的ip地址
#在docker中
export DISPLAY= XXX #把环境变量映射到主机IP
#在主机中
sudo gedit /etc/lightdm/lightdm.conf #增加一行 xserver-allow-tcp=true
sudo systemctl restart lightdm
xhost + #注意加号前应有空格
来源:oschina
链接:https://my.oschina.net/u/4409444/blog/4677673