linux服务器强化学习平台搭建(sumo安装)

Anaconda环境迁移

anaconda base 3.7.4

mujoco-py环境还没有配置安装mujoco-py因为注册表的原因

flow环境安装还有问题:已解决


tf-keras-rl

pip安装所需包时,出现错误

好像是pillow的问题,已解决。更换了一下安装顺序,把pillow最后安装

迁移方法与步骤

  • 安装Jetbrain toolbox,然后更改安装位置,安装pycharm

  • 安装anaconda,下载anaconda的包,bash安装

    • 原环境备份导出:

      # 激活将导出的环境
      conda activate environment
      # 将原有服务器上面的环境导出
      conda env export > environment.yaml
      # 导出pip安装的包
      pip freeze > requirement.txt
    • 目标机执行导入环境操作:

      conda env create -f environment.yaml
      # 进入新建的环境
      conda activate environment
      pip install -r requirement.txt
    • 检查tensorflow环境,pytorch环境,GPU,cuda等是否安装

      python
      import tensorflow as tf
      tf.test.is_built_with_cuda()
      tf.test.is_gpu_available() # 目前返回False说明还存在问题
  • SUMO安装

  • 安装下载Flow

  • 使用google Chrome,并且配置FQ插件

  • 搜狗输入法安装,记得把搜狗输入法置于第二位,不会显示乱码

SUMO安装

目前进展:

  • 根据flow的安装教程安装flow与sumo:https://github.com/flow-project/flow/blob/master/docs/source/flow_setup.rst#optional-direct-install-of-sumo-from-github

  • sumo安装出现问题:

    (base) ubuntu@host-192-168-96-5:~/data/sumo$ sudo apt-get install proj  libtool libgdal1-dev libxerces-c2-dev libfox-1.6-0 libfox-1.6-dev
    sudo: unable to resolve host host-192-168-96-5
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package libxerces-c2-dev is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    
    Package proj is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    
    E: Package 'proj' has no installation candidate
    E: Package 'libxerces-c2-dev' has no installation candidate
    

    (Optional) Direct install of SUMO from GitHub

    The below commands walk you through installing and building SUMO locally. Note that if this does not work, you are recommended to point an issue on the flow-dev message board or refer to SUMO's documentation regarding installing their software.

    We begin by downloading SUMO's github directory:

    cd ~
    git clone https://github.com/eclipse/sumo.git
    cd sumo
    git checkout 2147d155b1
    make -f Makefile.cvs

    If you have Ubuntu 14.04+, run the following command

    ./configure
    make -j$nproc
    echo 'export SUMO_HOME="$HOME/sumo"' >> ~/.bashrc
    echo 'export PATH="$HOME/sumo/bin:$PATH"' >> ~/.bashrc
    echo 'export PYTHONPATH="$HOME/sumo/tools:$PYTHONPATH"' >> ~/.bashrc
    source ~/.bashrc

    按照上面教程走到./configure之后出现错误:

    Optional features summary
    -------------------------
    Enabled: PROJ GDAL GUI
    Disabled: Debug Profiling Coverage PIC UnitTests Python OSG ffmpeg

    不用去管上述的错误,直接进行。要注意的是安装apt-get依赖的时候要根据第四个教程的ubuntu14.04的,而不是12.04的.。然后后续安装按照flow的教程

    主要根据第四份的教程

    1553240002264

    git checkout 2147d155b1
    297  make -f Makefile.cvs
    298  ./configure
    299  sudo apt-get install autoconf
    300  sudo apt-get install proj  libtool libgdal1-dev libxerces-c2-dev libfox-1.6-0 libfox-1.6-dev
    301  sudo ./configure --with-fox-includes=/usr/include/fox-1.6 --with-gdal-includes=/usr/include/gdal --with-proj-libraries=/usr/lib --with-gdal-libraries=/usr --with-proj-gdal
    302  sudo apt-get install autoconf
    303  sudo apt-get install libproj-dev proj-bin proj-data  libtool libgdal1-dev libxerces-c3-dev libfox-1.6-0 libfox-1.6-dev
    304  cd /usr/lib
    305  sudo ln -s libgdal1.7.0.so libgdal.so
    306  sudo ln -s libproj.so.0.7.0 proj-lib.so
    309  cd ~
    310  cd sumo
    311  cd data
    312  cd sumo
    313  sudo aclocal
    314  sudo automake
    315  sudo automake --add-missing
    316  sudo ./configure --with-fox-includes=/usr/include/fox-1.6 --with-gdal-includes=/usr/include/gdal --with-proj-libraries=/usr/lib --with-gdal-libraries=/usr --with-proj-gdal
    317  sudo make -j$nproc
    318  echo 'export SUMO_HOME="/home/ubuntu/data/sumo"' >> ~/.bashrc
    319  echo 'export PATH="/home/ubuntu/data/sumo/bin:$PATH"' >> ~/.bashrc
    320  echo 'export PYTHONPATH="/home/ubuntu/data/sumo/tools:$PYTHONPATH"' >> ~/.bashrc
    321  source ~/.bashrc
    322  sumo-gui
    323  sumo
    324  echo $SUMO_HOME
    325 (base) ubuntu@host-192-168-96-5:~/data/sumo$ 

    用上述方法就不需要移动sumo文件到处都是,就在data/sumo下面,这样就比较清晰
    要使用pycharm还要设置环境变量SUMO_HOME和添加tools:
    安装完成后:确保sumo-*下有四个文件夹--未必
    而且在终端命令行输入sumo或者sumo-gui都可以执行
    最后更改环境变量gedit ~/.bashrc source ~/.bashrc

  • 如果使用的是pycharm编译器,需要更改edit Configurations与Project Structure
    Edit Configurations:RUN下面,是添加SUMO_HOME环境变量,即sumo-*所在的位置

    Project Structure:添加sumo下的tools文件夹路径。file ->settings ->project ->project structure ->Add Content Root ->选择sumo的tools文件夹路径 ->ok

  • 或者从终端启用Pycharm
    具体原因来自于PyCharm ignoring LD_LIBRARY_PATH from .bashrc

升级至sumo-1.6.0

sumo 1.1.0之后的版本不支持上述方式安装了,只能使用https://sumo.dlr.de/docs/Installing/Linux_Build.html安装,但是不能与其他版本共存,于是先不升级。sumo1.1之后的版本更好安装了。

按照教程来吧,网址如下哟:

https://sumo.dlr.de/docs/Installing/Linux_Build.html#Building_the_SUMO_binaries_with_cmakesumo.dlr.de

让我们开始吧~

hold on,如果你已经安装过sumo,需要先卸载旧的版本哦。如果你从未装过sumo,跳过卸载的步骤。


卸载sumo,分两种类型

1)若是apt-get 安装,则直接apt-get remove

sudo apt-get remove sumo
sudo apt-get remove sumo-tools
sudo apt-get remove sumo-docs

2)若是make install编译安装,则

参考: https://stackoverflow.com/questions/36256049/uninstall-sumo-0-22

试试下面三种方法

i)在sudo make install的目录下执行:sudo make uninstall

ii)如果你找不到安装目录啦,去/usr/local/bin删除下面的文件

cd /usr/local/bin
sudo rm activitygen dfrouter emissionsDrivingCycle jtrrouter marouter od2trips sumo-gui TraCITestClient duarouter emissionsMap netconvert netgenerate polyconvert sumo

iii)如果你还能找到安装目录,进入sumo的bin文件目录,删除下面的文件

sudo rm activitygen dfrouter emissionsDrivingCycle jtrrouter marouter od2trips sumo-gui TraCITestClient duarouter emissionsMap netconvert netgenerate polyconvert sumo

最后,记得删除整个sumo文件夹,sudo rm -r+你的SUMO版本


下面进入正题,参考官方教程[https://sumo.dlr.de/docs/Installing/Linux_Build.html#Building_the_SUMO_binaries_with_cmake] 安装sumo-1.5.0啦

  1. 首先,安装需要的库和依赖

    sudo apt-get install cmake python g++ libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev swig
  2. 下载安装包
    去这里下载安装包:https://sourceforge.net/projects/sumo/files/sumo/
    我下载的是sumo-src-1.5.0.tar.gz

  3. 在home下解压,然后

    tar xzf sumo-src-1.5.0.tar.gz
    cd sumo-1.5.0
    pwd 
  4. 修改SUMO_HOME路径

    export SUMO_HOME="/home/<user>/sumo-1.5.0"
    echo $SUMO_HOME

    结果应该显示:/home/<用户名>/sumo-1.5.0

  5. 用到cmake开始build

    mkdir build/cmake-build
    cd build/cmake-build
    cmake ../..
  6. make

    make -j $(nproc)

    或者

    make -j $(grep -c ^processor /proc/cpuinfo)

可能的问题:

  1. 终端输入sumo-gui不能打开sumo仿真界面?
    试试下面的方法呢
    首先打开bashrc:

    sudo gedit ~/.bashrc

    添加:

    export PATH=/home/[我的用户名]/sumo-1.5.0/bin:$PATH

    记得让修改的路径生效:

    source ~/.bashrc

升级至sumo-1.7.0

  1. 可以不用卸载原来的包data/sumo
  2. 下载安装包到任意位置,包名通常为sumo-x.x.x
  3. 步骤如上
  4. 编译成功后将sumo-x.x.x移动到data并重命名为data/sumo这样就可以不用更改~/.bashrc文件

本次安装出现问题:

//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFFdOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFSetField@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
src/polyconvert/CMakeFiles/polyconvert.dir/build.make:346: recipe for target '../../bin/polyconvertD' failed
make[2]: *** [../../bin/polyconvertD] Error 1
CMakeFiles/Makefile2:2711: recipe for target 'src/polyconvert/CMakeFiles/polyconvert.dir/all' failed
make[1]: *** [src/polyconvert/CMakeFiles/polyconvert.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFFdOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFSetField@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
src/netgen/CMakeFiles/netgenerate.dir/build.make:241: recipe for target '../../bin/netgenerateD' failed
make[2]: *** [../../bin/netgenerateD] Error 1
CMakeFiles/Makefile2:2199: recipe for target 'src/netgen/CMakeFiles/netgenerate.dir/all' failed
make[1]: *** [src/netgen/CMakeFiles/netgenerate.dir/all] Error 2
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFFdOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFSetField@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
src/CMakeFiles/netconvert.dir/build.make:115: recipe for target '../../bin/netconvertD' failed
make[2]: *** [../../bin/netconvertD] Error 1
CMakeFiles/Makefile2:614: recipe for target 'src/CMakeFiles/netconvert.dir/all' failed
make[1]: *** [src/CMakeFiles/netconvert.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

make -j $(nproc)之后出现上述问题,分析后是因为libtiff包在anaconda3里面产生冲突

locate libtiff.so
/home/ubuntu/data/anacond3/envs/node33-base/lib/libtiff.so
/home/ubuntu/data/anacond3/envs/node33-base/lib/libtiff.so.5
/home/ubuntu/data/anacond3/envs/node33-base/lib/libtiff.so.5.4.0
/home/ubuntu/data/anacond3/envs/tf-keras-rl/lib/libtiff.so
/home/ubuntu/data/anacond3/envs/tf-keras-rl/lib/libtiff.so.5
/home/ubuntu/data/anacond3/envs/tf-keras-rl/lib/libtiff.so.5.4.0
/home/ubuntu/data/anacond3/envs/tf_gpu_env/lib/libtiff.so
/home/ubuntu/data/anacond3/envs/tf_gpu_env/lib/libtiff.so.5
/home/ubuntu/data/anacond3/envs/tf_gpu_env/lib/libtiff.so.5.2.4
/home/ubuntu/data/anacond3/lib/libtiff.so
/home/ubuntu/data/anacond3/lib/libtiff.so.5
/home/ubuntu/data/anacond3/lib/libtiff.so.5.5.0
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-h2733197_2/lib/libtiff.so
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-h2733197_2/lib/libtiff.so.5
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-h2733197_2/lib/libtiff.so.5.4.0
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-hfc65ed5_1004/lib/libtiff.so
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-hfc65ed5_1004/lib/libtiff.so.5
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.10-hfc65ed5_1004/lib/libtiff.so.5.4.0
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.6-3/lib/libtiff.so
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.6-3/lib/libtiff.so.5
/home/ubuntu/data/anacond3/pkgs/libtiff-4.0.6-3/lib/libtiff.so.5.2.4
/home/ubuntu/data/anacond3/pkgs/libtiff-4.1.0-h2733197_1/lib/libtiff.so
/home/ubuntu/data/anacond3/pkgs/libtiff-4.1.0-h2733197_1/lib/libtiff.so.5
/home/ubuntu/data/anacond3/pkgs/libtiff-4.1.0-h2733197_1/lib/libtiff.so.5.5.0
/usr/lib/x86_64-linux-gnu/libtiff.so
/usr/lib/x86_64-linux-gnu/libtiff.so.5
/usr/lib/x86_64-linux-gnu/libtiff.so.5.2.4

然后把 anaconda3下面的 libtiff.so移走

mkdir /home/ubuntu/data/bak
mv /home/ubuntu/data/anacond3/lib/libtiff.so* ~/data/bak/

重新编译后成功


tf_gpu_env下安装mujoco的情况:

按照教程已安装好mujoco150,运行:

./simulate ../model/humanoid.xml

结果:


出现无法显示的问题,先暂且到这儿。

posted @ 2020-09-22 17:26  xlchan  阅读(2020)  评论(0编辑  收藏  举报